Ferricstore.Raft.BlobCommand (ferricstore v0.4.2)

Copy Markdown View Source

Prepares large-value Raft commands for blob side-channel replication.

The ref-only command shapes are only safe for a single-member Raft group: the local apply side can validate that the blob record already exists before it stores the ref in Bitcask. Multi-member groups still need a blob transfer protocol before followers can apply refs without the original payload.

Summary

Functions

Extracts the encoded blob ref from a Flow value marker.

Returns a command that can be submitted to Raft.

Returns true when command contains a value that would use the blob side-channel if the Raft group is eligible.

Types

command()

@type command() ::
  {:put, binary(), binary(), non_neg_integer()}
  | {:set, binary(), binary(), non_neg_integer(), map()}
  | {:append, binary(), binary()}
  | {:getset, binary(), binary()}
  | {:setrange, binary(), non_neg_integer(), binary()}
  | {:cas, binary(), binary(), binary(), non_neg_integer() | nil}
  | {:locked_put, binary(), binary(), non_neg_integer(), term()}
  | {:compound_put, binary(), binary(), non_neg_integer()}
  | {:compound_batch_put, binary(), [{binary(), binary(), non_neg_integer()}]}
  | {:put_batch, [{binary(), binary(), non_neg_integer()}]}
  | term()

Functions

flow_blob_value_ref(arg1)

@spec flow_blob_value_ref(term()) :: {:ok, binary()} | :error

Extracts the encoded blob ref from a Flow value marker.

Flow payload/result/error values are encoded before they enter the blob store, so apply can store a ref to the encoded Flow value without re-encoding bytes.

prepare(ctx, shard_index, command, opts \\ [])

@spec prepare(map(), non_neg_integer(), command(), keyword()) ::
  {:ok, command()} | {:error, term()}

Returns a command that can be submitted to Raft.

When side-channel storage is disabled, or the Raft group has more than one member, commands are returned unchanged. In one-node mode, large values are written to the blob store first and Raft receives only the small encoded ref.

put_blob_payloads(data_dir, shard_index, payloads)

side_channel_candidate?(ctx, command)

@spec side_channel_candidate?(map(), command()) :: boolean()

Returns true when command contains a value that would use the blob side-channel if the Raft group is eligible.

Batcher uses this as a cheap hot-path guard so enabling a large-value threshold does not force a Ra membership lookup for every tiny SET.