View Source FDBC.Tenant (fdbc v0.1.4)
Represents a FoundationDB tenant. Tenants are optional named transaction domains that can be used to provide multiple disjoint key-spaces to client applications. A transaction created in a tenant will be limited to the keys contained within that tenant, and transactions operating on different tenants can use the same key names without interfering with each other.
Summary
Types
@type t() :: %FDBC.Tenant{resource: term()}
Functions
@spec async_get_id(t()) :: FDBC.Future.t(integer())
The same as get_id/1
except it returns the unresolved future.
@spec create(FDBC.Database.t() | FDBC.Transaction.t(), binary() | [any()]) :: :ok
Creates a new tenant in the cluster.
The tenant name can be either a binary or a tuple and cannot start with the
\xff
byte. If a tuple is provided, the tuple will be packed using the
tuple layer to generate the byte string tenant name.
If a database is provided to this function for the database_or_transaction
parameter, then this function will first check if the tenant already exists.
If it does, it will fail with a tenant_already_exists
error. Otherwise, it
will create a transaction and attempt to create the tenant in a retry loop.
If the tenant is created concurrently by another transaction, this function
may still return successfully.
If a transaction is provided to this function for the
database_or_transaction
parameter, then this function will not check if the
tenant already exists. It is up to the user to perform that check if
required. The user must also successfully commit the transaction in order for
the creation to take effect.
@spec delete(FDBC.Database.t() | FDBC.Transaction.t(), binary() | [any()]) :: :ok
Delete a tenant from the cluster.
The tenant name can be either a binary or a tuple. If a tuple is provided, the tuple will be packed using the tuple layer to generate the byte string tenant name.
It is an error to delete a tenant that still has data. To delete a non-empty tenant, first clear all of the keys in the tenant.
If a database is provided to this function for the database_or_transaction
parameter, then this function will first check if the tenant already exists.
If it does not, it will fail with a tenant_not_found error. Otherwise, it
will create a transaction and attempt to delete the tenant in a retry loop.
If the tenant is deleted concurrently by another transaction, this function
may still return successfully.
If a transaction is provided to this function for the
database_or_transaction
parameter, then this function will not check if the
tenant already exists. It is up to the user to perform that check if
required. The user must also successfully commit the transaction in order for
the deletion to take effect.
Gets the ID for a given tenant.
The ID is the unique identifier assigned to the tenant by the cluster upon its creation.
@spec list(FDBC.Database.t() | FDBC.Transaction.t(), binary(), binary(), keyword()) :: :ok
Lists the tenants in the cluster.
Tenants are fetched for the given name range and limit. Returning a list of key value pairs representing the tenants in the cluster where the key is the tenant name, while the value is a JSON blob of the tenant's metadata.
Options
:limit
- (integer) Indicates the maximum number of key-value tenant pairs to return.
@spec open(FDBC.Database.t(), binary()) :: t()
Opens a tenant on the given database.
All transactions created by this tenant will operate on the tenant’s key-space.