Bedrock.DataPlane.CommitProxy.RoutingData (bedrock v0.6.0)
View SourceManages routing data for the commit proxy.
Encapsulates all information needed to route mutations to logs:
shard_table- ETS ordered_set for key → tag ceiling searchlog_map- Map of index → log_id for golden ratio routinglog_services- Map of log_id → {otp_name, node} for contacting logsreplication_factor- Number of logs per mutation
Lifecycle
new_empty/0- Creates empty routing data for dynamic populationcleanup/1- Deletes the ETS table when the commit proxy terminates
Shard Updates
insert_shard/3- Adds or updates a shard entrydelete_shard/2- Removes a shard entry
Log Updates
insert_log/2- Adds a log to log_map at next indexremove_log/2- Removes a log and reindexesput_log_service/3- Adds or updates a log service referencedelete_log_service/2- Removes a log service referenceset_replication_factor/2- Updates the replication factor
Summary
Functions
Applies metadata mutations to update routing data.
Cleans up routing data by deleting the ETS table.
Removes a log service reference.
Deletes a shard entry from the routing table.
Adds a log to the log_map at the next available index.
Inserts or updates a shard entry in the routing table.
Creates empty routing data for dynamic population via metadata.
Adds or updates a log service reference.
Removes a log from the log_map and reindexes remaining entries.
Updates the replication factor.
Types
@type t() :: %Bedrock.DataPlane.CommitProxy.RoutingData{ log_map: %{required(non_neg_integer()) => Bedrock.DataPlane.Log.id()}, log_services: %{required(Bedrock.DataPlane.Log.id()) => {atom(), node()}}, replication_factor: pos_integer(), shard_table: :ets.table() }
Functions
Applies metadata mutations to update routing data.
Handles shard_key and layout_log mutations:
- shard_key: Updates ETS shard_table
- layout_log: Updates both log_map and log_services
Parameters
routing_data- Current routing dataupdates- List of{version, [mutations]}tuples from resolver
Returns
Updated routing data with applied mutations.
@spec cleanup(t() | nil) :: true
Cleans up routing data by deleting the ETS table.
Safe to call with nil or if the table has already been deleted.
@spec delete_log_service(t(), Bedrock.DataPlane.Log.id()) :: t()
Removes a log service reference.
Deletes a shard entry from the routing table.
Called from apply_mutations/2 when processing shard_key clear mutations.
@spec insert_log(t(), Bedrock.DataPlane.Log.id()) :: t()
Adds a log to the log_map at the next available index.
Inserts or updates a shard entry in the routing table.
Called from apply_mutations/2 when processing shard_key mutations.
@spec new_empty() :: t()
Creates empty routing data for dynamic population via metadata.
Starts with an empty shard table, no logs, and replication factor of 1. All fields are populated incrementally as metadata mutations arrive.
@spec put_log_service(t(), Bedrock.DataPlane.Log.id(), {atom(), node()}) :: t()
Adds or updates a log service reference.
@spec remove_log(t(), Bedrock.DataPlane.Log.id()) :: t()
Removes a log from the log_map and reindexes remaining entries.
Maintains contiguous indices starting from 0.
@spec set_replication_factor(t(), pos_integer()) :: t()
Updates the replication factor.