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, and atomic adds.
- Watches. Notifications when a key changes.
- Versionstamps. Unique, globally ordered write stamps, used for FIFO queuing.
- Directory layer. Tuple-key packing, range calculation, and 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. Every watch and future operation
must return a {dgen_future, Ref, BackendData} tuple. Ref is a reference, and
the backend later sends {Ref, ready} 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.
This documentation is LLM-generated. See the AI disclosure in README.md.
Summary
Functions
Runs Fun inside a transaction if Handle is a database handle,
or calls Fun directly if Handle is already a transaction.