Bedrock.ControlPlane.Coordinator.Commands (bedrock v0.5.3)

View Source

Structured command types for Raft consensus operations.

All coordinator operations that require consensus should use these structured commands instead of raw data.

Summary

Functions

Create a command to deregister services via consensus.

Create a command to end the previous epoch via consensus. This triggers the initial consensus round needed for director startup.

Create a command to MERGE node resources (services and capabilities) via consensus. MERGE semantics: adds/updates specified resources, preserves existing unspecified resources. Use for incremental service registration (e.g., individual worker advertisement).

Create a command to register services via consensus.

Create a command to SET node resources (services and capabilities) via consensus. SET semantics: completely replaces all resources for the specified node. Use for initial node registration or complete resource declarations.

Types

command()

deregister_services_command()

@type deregister_services_command() ::
  {:deregister_services, %{service_ids: [String.t()]}}

end_epoch_command()

@type end_epoch_command() :: {:end_epoch, Bedrock.epoch() | nil}

merge_node_resources_command()

@type merge_node_resources_command() ::
  {:merge_node_resources,
   %{
     node: node(),
     services: [service_info()],
     capabilities: [Bedrock.Cluster.capability()]
   }}

register_services_command()

@type register_services_command() ::
  {:register_services, %{services: [service_info()]}}

service_info()

@type service_info() ::
  {service_id :: String.t(), kind :: atom(), worker_ref :: {atom(), node()}}

set_node_resources_command()

@type set_node_resources_command() ::
  {:set_node_resources,
   %{
     node: node(),
     services: [service_info()],
     capabilities: [Bedrock.Cluster.capability()]
   }}

Functions

deregister_services(service_ids)

@spec deregister_services([String.t()]) :: deregister_services_command()

Create a command to deregister services via consensus.

end_epoch(previous_epoch)

@spec end_epoch(Bedrock.epoch() | nil) :: end_epoch_command()

Create a command to end the previous epoch via consensus. This triggers the initial consensus round needed for director startup.

merge_node_resources(node, services, capabilities)

@spec merge_node_resources(node(), [service_info()], [Bedrock.Cluster.capability()]) ::
  merge_node_resources_command()

Create a command to MERGE node resources (services and capabilities) via consensus. MERGE semantics: adds/updates specified resources, preserves existing unspecified resources. Use for incremental service registration (e.g., individual worker advertisement).

register_services(services)

@spec register_services([service_info()]) :: register_services_command()

Create a command to register services via consensus.

set_node_resources(node, services, capabilities)

@spec set_node_resources(node(), [service_info()], [Bedrock.Cluster.capability()]) ::
  set_node_resources_command()

Create a command to SET node resources (services and capabilities) via consensus. SET semantics: completely replaces all resources for the specified node. Use for initial node registration or complete resource declarations.