Behaviour defining the storage backend for dgen.
A backend must implement all required callbacks to provide:
- Transactions — serializable read-write transactions over the keyspace.
- Key-value operations — get, set, clear, range reads, atomic adds.
- Watches — notifications when a key changes.
- Versionstamps — globally-ordered, unique write stamps for FIFO queuing.
- Directory layer — tuple-key packing, range calculation, namespace isolation.
The default backend is dgen_erlfdb, which delegates to FoundationDB via the
erlfdb library.
We look forward to changing the backend interface to support other systems.
Configuring the backend
Set the backend application env before starting dgen:
application:set_env(dgen, backend, my_backend).Or in config.exs:
config :dgen, backend: MyBackendImplementing a backend
A backend module must implement this behaviour. All watch and future operations
must return {dgen_future, Ref, BackendData} tuples where Ref is a reference
that will appear in a {Ref, ready} message sent to the watching process.
Types
Backends define opaque types for database handles, transaction handles, directory handles, and futures. The dgen core treats these as opaque terms and only passes them back into backend callbacks.
Summary
Functions
Runs Fun inside a transaction if Handle is a database handle,
or calls Fun directly if Handle is already a transaction.