View Source FDBC (fdbc v0.1.4)
An unofficial FoundationDB client for Elixir.
FoundationDB is a distributed database designed to handle large volumes of structured data across clusters of commodity servers. It organises data as an ordered key-value store and employs ACID transactions for all operations. It is especially well-suited for read/write workloads but also has excellent performance for write-intensive workloads.
This documentation makes use of and refers to the upstream documentation where it makes sense.
Foundation
FDBC.Foundation
is a wrapper around the database geared at easing use within applications.
defmodule Demo.Foundation do
use FDBC.Foundation,
otp_app: :demo,
options: [
transaction_retry_limit: 100,
transaction_timeout: 60_000
]
end
Where the configuration for the Foundation must be in your application
environment, usually defined in your config/config.exs
:
config :demo, Demo.Foundation,
cluster: "./fdb.cluster",
directory: "demo"
If your application was generated with a supervisor you will have a
lib/demo/application.ex
file containing the application start callback that
defines and starts your supervisor. You just need to edit the start/2
function to start the repo as a supervisor on your application's supervisor:
def start(_type, _args) do
children = [
Demo.Foundation,
]
opts = [strategy: :one_for_one, name: Demo.Supervisor]
Supervisor.start_link(children, opts)
end
Summary
Functions
Specifies the version of the API that the application uses. This allows future versions of FoundationDB to make API changes without breaking existing programs.
Performs a transaction against the database.
Functions
@spec api_version(integer() | nil) :: :ok
Specifies the version of the API that the application uses. This allows future versions of FoundationDB to make API changes without breaking existing programs.
If the version is not specified the latest currently supported API version is used.
Note
This function must be called before any other part of this library, unless being used as part of an OTP application.
@spec transact( FDBC.Database.t() | FDBC.Transaction.t(), (FDBC.Transaction.t() -> any()), keyword() ) :: any()
Performs a transaction against the database.
This is a convenience funtion that will create a transaction, passing it to the provided function, committing it and handling any retry logic based on the error returned.
Furthermore a transaction can be passed to this function in which case it logically does nothing, this is useful to allow composition of transactional functions.
The options are used for creating the transaction and therefore are the same
as those for FDBC.Transaction.create/2
.