Nebula
Control plane

ControlPlaneJson

The control plane as one JSON document, and one control-plane write as one JSON object.

generated from the sources
public static class ControlPlaneJson

The control plane as one JSON document, and one control-plane write as one JSON object. This is the wire format between RemoteControlPlane (workers, gateways) and ControlPlaneHost (the orchestrator), and the format the host stores through IControlPlaneStorage.

Snapshot: {"version":N,"now":unixMs,"workers":[...],"leases":[...],"gateways":[...],"settings":{...}}. Write: {"op":"RegisterWorker","workerId":"w1",...}; a request carries a list of them under "ops", applied in order. Times are Unix milliseconds; vectors are [x, y, z].

Fields

RegisterWorker, HeartbeatWorker, UnregisterWorker, RegisterGateway, HeartbeatGateway, UnregisterGateway, SetGatewayDraining, HeartbeatOrchestrator, SetSetting, EnsureContainer, EnsureRuntimeContainer, TouchContainer, AssignContainer, PinContainer, SetLeaseState, ReleaseContainer, RemoveContainer, ResetControlPlane, SetContainerHint, SetContainerCapacity, ActivateScope, RemoveScope, SetScopeState, AckScopePart

public const string RegisterWorker = "RegisterWorker", HeartbeatWorker = "HeartbeatWorker", UnregisterWorker = "UnregisterWorker", RegisterGateway = "RegisterGateway", HeartbeatGateway = "HeartbeatGateway", UnregisterGateway = "UnregisterGateway", SetGatewayDraining = "SetGatewayDraining", HeartbeatOrchestrator = "HeartbeatOrchestrator", SetSetting = "SetSetting", EnsureContainer = "EnsureContainer", EnsureRuntimeContainer = "EnsureRuntimeContainer", TouchContainer = "TouchContainer", AssignContainer = "AssignContainer", PinContainer = "PinContainer", SetLeaseState = "SetLeaseState", ReleaseContainer = "ReleaseContainer", RemoveContainer = "RemoveContainer", ResetControlPlane = "ResetControlPlane", SetContainerHint = "SetContainerHint", SetContainerCapacity = "SetContainerCapacity", ActivateScope = "ActivateScope", RemoveScope = "RemoveScope", SetScopeState = "SetScopeState", AckScopePart = "AckScopePart";

Names of the writes, as they travel on the wire.

Methods

Write

public static string Write(long version, DateTime now, IReadOnlyList<WorkerInfo> workers, IReadOnlyList<LeaseInfo> leases, IReadOnlyList<GatewayInfo> gateways, IReadOnlyDictionary<string, string> settings, IReadOnlyList<ScopeInfo> scopes = null, string documentId = null);

Parse

public static Snapshot Parse(string json);

Read a snapshot written by Write. Throws FormatException on malformed input.

WriteGatewayStats

public static void WriteGatewayStats(JsonWriter w, in GatewayStats s);

The gateway's self-report, flat on the row (and on the HeartbeatGateway op) so old and new readers agree on "pendingJoins".

ReadGatewayStats

public static GatewayStats ReadGatewayStats(Dictionary<string, object> o);

WriteBatch

public static string WriteBatch(IReadOnlyList<string> ops);

Wrap a batch of writes in the request body ControlPlaneHost reads.

ApplyBatch

public static string ApplyBatch(string body, IControlPlane target);

Apply every write in body ({"ops":[...]}) to target, in order. Returns null, or the reason the body was rejected (nothing is applied then).

CauseOf

public static SaturationCause CauseOf(string name);

The saturation cause a wire name (SaturationReport.NameOf) stands for; anything unknown reads as none.

ToUnixMs

public static long ToUnixMs(DateTime t);

FromUnixMs

public static DateTime FromUnixMs(double ms);

Num

public static void Num(JsonWriter w, float f);
public static void Num(JsonWriter w, double d);
public static double Num(Dictionary<string, object> o, string key);

A float at full precision (JsonWriter.Value rounds to three decimals).

Vec

public static void Vec(JsonWriter w, Vector3 v);
public static void Vec(JsonWriter w, Double3 v);
public static Vector3 Vec(Dictionary<string, object> o, string key);

Vec3D

public static Double3 Vec3D(Dictionary<string, object> o, string key);

AuthorityName

public static string AuthorityName(ContainerAuthority a);

The wire name of an authority mode ("leased", "inherited"; "" for auto).

AuthorityOf

public static ContainerAuthority AuthorityOf(string name);

PlacementOf

public static ContainerPlacement PlacementOf(Dictionary<string, object> o);

The placement an EnsureRuntimeContainer op carries (an op written before placements existed reads as a root).

Placement

public static OpWriter Placement(OpWriter op, in ContainerPlacement p);

Write a placement as the arguments of an EnsureRuntimeContainer op.

SectionsObject

public static void SectionsObject(JsonWriter w, string key, string compact);

Writes a worker's name=ms name=ms profile string (see WorkerStats.ProfileSections) as a JSON object of numbers, so /api/state readers get a map; an empty or missing string writes {}.

Str

public static string Str(Dictionary<string, object> o, string key);

Bool

public static bool Bool(Dictionary<string, object> o, string key);

Nested types

Snapshot

public sealed class Snapshot

Everything a subscriber needs, as plain lists (see Parse).

Fields

Version
public long Version;
Now
public DateTime Now;
DocumentId
public string DocumentId = "";

The IControlPlane.DocumentId value, or an empty string when the JSON omits it.

Workers
public List<WorkerInfo> Workers = new List<WorkerInfo>();
Leases
public List<LeaseInfo> Leases = new List<LeaseInfo>();
Gateways
public List<GatewayInfo> Gateways = new List<GatewayInfo>();
Settings
public Dictionary<string, string> Settings = new Dictionary<string, string>();
Scopes
public List<ScopeInfo> Scopes = new List<ScopeInfo>();

Activated simulation scopes (ScopeInfo). Empty for a document written before scope activation.

OpWriter

public sealed class OpWriter

Builds one write object. Call Op then the Arg overloads, then End.

Methods

Op
public OpWriter Op(string name);

A fresh writer per object: the previous one still thinks a comma is due after its closing brace.

Arg
public OpWriter Arg(string name, string value);
public OpWriter Arg(string name, long value);
public OpWriter Arg(string name, ulong value);
public OpWriter Arg(string name, uint value);
public OpWriter Arg(string name, bool value);
public OpWriter Arg(string name, float value);
public OpWriter Arg(string name, Vector3 value);
public OpWriter Arg(string name, Double3 value);
End
public string End();

On this page