FerricStore.SDK.Native.Topology (ferricstore_sdk v0.4.2)

Copy Markdown View Source

Read-only snapshot of the cluster topology used by the topology-aware SDK.

FerricStore.SDK.topology/1 returns this struct. route_epoch identifies the server routing version, shard_count is the number of represented shards, control_endpoint caches the deterministic control-plane target, and endpoints contains effective endpoints keyed by transport identity. slots is the SDK's immutable 1,024-entry routing table.

Applications may inspect a snapshot, but routing should go through FerricStore.SDK.route/2 so future topology updates are observed.

Summary

Types

connection_key()

@type connection_key() ::
  {:gen_tcp, binary(), non_neg_integer(), term()}
  | {:ssl, binary(), non_neg_integer(), term(), term()}

endpoint()

@type endpoint() :: %{
  :node => binary(),
  :host => binary(),
  :native_port => non_neg_integer(),
  optional(:native_tls_port) => non_neg_integer(),
  optional(:tls) => boolean(),
  optional(:server_name) => binary() | charlist(),
  optional(:verify) => boolean(),
  optional(:tls_verify) => boolean(),
  optional(:cacertfile) => binary() | charlist(),
  optional(:cacerts) => list() | struct()
}

t()

@type t() :: %FerricStore.SDK.Native.Topology{
  control_endpoint: endpoint() | nil,
  endpoints: %{optional(connection_key()) => endpoint()},
  route_epoch: non_neg_integer(),
  shard_count: non_neg_integer(),
  slots: tuple()
}

Functions

build(payload, opts \\ [])

@spec build(
  map(),
  keyword()
) :: {:ok, t()} | {:error, term()}

endpoint_key(endpoint)

@spec endpoint_key(map()) :: connection_key()

route_key(topology, key)

@spec route_key(t(), term()) :: {:ok, map()} | {:error, term()}

slot_for_key(key)

@spec slot_for_key(binary()) :: non_neg_integer()