Bedrock.DataPlane.CommitProxy.ResolverLayout (bedrock v0.5.3)

View Source

Struct variants for resolver configuration, enabling pattern matching to optimize single vs sharded resolver paths in transaction finalization.

Summary

Functions

Calculates the end key boundaries for each resolver.

Creates a ResolverLayout from a TransactionSystemLayout.

Types

Functions

calculate_resolver_ends(resolvers)

@spec calculate_resolver_ends([{Bedrock.key(), Bedrock.DataPlane.Resolver.ref()}]) ::
  [
    {Bedrock.key(), Bedrock.DataPlane.Resolver.ref()}
  ]

Calculates the end key boundaries for each resolver.

Given a list of resolvers with their start keys, computes the exclusive end key for each resolver's range. The last resolver's range extends to the maximum key.

Returns

A list of {end_key, resolver_ref} tuples where end_key is the exclusive upper bound for that resolver's key range.

from_layout(map)

Creates a ResolverLayout from a TransactionSystemLayout.

Returns a Single struct for single-resolver configurations, or a Sharded struct for multi-resolver configurations. This enables efficient pattern matching in the finalization pipeline.

Examples

iex> layout = %TransactionSystemLayout{resolvers: [{"", resolver_pid}]}
iex> ResolverLayout.from_layout(layout)
%ResolverLayout.Single{resolver_ref: resolver_pid}

iex> layout = %TransactionSystemLayout{resolvers: [{"", pid1}, {"\x80", pid2}]}
iex> ResolverLayout.from_layout(layout)
%ResolverLayout.Sharded{resolver_ends: [...], resolver_refs: [pid1, pid2]}