Shared routing helpers used by distributed high-level stores.
Partition resolution
Two consistent schemes are provided — pick one per access pattern:
- Concrete-key helpers (
route_put/2,route_delete/2,local_get/2,local_insert_new/2,local_take/2) resolve the partition from the record or record key itself, so writes, reads and deletes for the same key always land on the same table. The second argument is accepted for API compatibility and ignored. - Pattern helpers (
local_match/2,route_delete_match/2) cannot hash a match pattern (wildcards change the term), so they scope to a namespace: the partition is derived from the namespace argument and all records for one store must therefore embed that namespace in their key.
Read routing
Reads always go to the local ETS table (eventual consistency by default).
Pass read_mode: :primary at the API layer where strong consistency is
required.
Summary
Functions
Read ets_key from its partition.
insert_new on the record's partition.
Match-object scan on the namespace's partition.
take on the record's partition.
Route a delete of ets_key, partitioned by the key itself.
Route a pattern delete scoped to the partition derived from namespace.
Route a put of the record {ets_key, value} to the partition derived
from ets_key.
Functions
Read ets_key from its partition.
insert_new on the record's partition.
Match-object scan on the namespace's partition.
take on the record's partition.
Route a delete of ets_key, partitioned by the key itself.
Route a pattern delete scoped to the partition derived from namespace.
Route a put of the record {ets_key, value} to the partition derived
from ets_key.