Bedrock.Directory (bedrock v0.6.0)
View SourceFoundationDB directory layer operations.
Directories provide a hierarchical namespace for organizing data within a FoundationDB database. Each directory corresponds to a unique prefix that can be used to create isolated keyspaces.
Based on the FoundationDB directory layer specification.
Summary
Functions
Creates a directory at the given path.
Creates or opens a directory at the given path.
Checks if a directory exists at the given path.
Returns the layer identifier of this directory, or nil if none.
Lists the immediate subdirectories of the given path.
Moves a directory from old_path to new_path.
Opens an existing directory at the given path.
Returns the path of this directory as a list of strings.
Removes a directory and all its subdirectories.
Removes a directory if it exists.
Creates a new directory layer.
Returns a Bedrock.Keyspace for this directory.
Types
@type directory() :: Bedrock.Directory.Node.t() | Bedrock.Directory.Partition.t() | Bedrock.Directory.Layer.t()
Functions
@spec create(directory(), [String.t()], keyword()) :: {:ok, directory()} | {:error, :directory_already_exists} | {:error, :parent_directory_does_not_exist} | {:error, :invalid_path}
Creates a directory at the given path.
Returns {:ok, directory} if successful, or {:error, reason} if the
directory already exists or the parent directory does not exist.
Options
:layer- Layer identifier for the directory (binary):prefix- Manual prefix assignment (binary):version- Version metadata for the directory (term):metadata- Additional metadata for the directory (term)
@spec create_or_open(directory(), [String.t()], keyword()) :: {:ok, directory()} | {:error, :parent_directory_does_not_exist} | {:error, :invalid_path}
Creates or opens a directory at the given path.
If the directory exists, opens it. Otherwise, creates it.
Options
:layer- Layer identifier for the directory (binary):prefix- Manual prefix assignment (binary):version- Version metadata for the directory (term):metadata- Additional metadata for the directory (term)
@spec do_create(Bedrock.Directory.Layer.t(), term(), [String.t()], keyword()) :: {:ok, Bedrock.Directory.Node.t()} | {:error, atom()}
@spec do_exists?(Bedrock.Directory.Layer.t(), [String.t()]) :: boolean()
@spec do_list(Bedrock.Directory.Layer.t(), term(), [String.t()]) :: {:ok, [String.t()]} | {:error, atom()}
@spec do_move(Bedrock.Directory.Layer.t(), term(), [String.t()], [String.t()]) :: :ok | {:error, atom()}
@spec do_open(Bedrock.Directory.Layer.t(), term(), [String.t()]) :: {:ok, Bedrock.Directory.Node.t() | Bedrock.Directory.Partition.t()} | {:error, atom()}
@spec do_remove(Bedrock.Directory.Layer.t(), term(), [String.t()]) :: :ok | {:error, atom()}
Checks if a directory exists at the given path.
@spec is_prefix_free?(Bedrock.Directory.Layer.t(), term(), binary()) :: boolean()
Returns the layer identifier of this directory, or nil if none.
Lists the immediate subdirectories of the given path.
Returns a list of subdirectory names (strings).
@spec move(directory(), [String.t()], [String.t()]) :: :ok | {:error, :directory_does_not_exist} | {:error, :directory_already_exists} | {:error, :parent_directory_does_not_exist}
Moves a directory from old_path to new_path.
The directory and all its subdirectories are moved atomically.
@spec open(directory(), [String.t()]) :: {:ok, directory()} | {:error, :directory_does_not_exist} | {:error, :invalid_path}
Opens an existing directory at the given path.
Returns {:ok, directory} if successful, or {:error, :directory_does_not_exist}
if the directory does not exist.
Returns the path of this directory as a list of strings.
Removes a directory and all its subdirectories.
Returns an error if the directory does not exist.
Removes a directory if it exists.
Returns :ok whether the directory existed or not.
@spec root( module(), keyword() ) :: Bedrock.Directory.Node.t()
Creates a new directory layer.
Arguments
repo- Module implementing Bedrock.Repo behaviour (required)
Options
:next_prefix_fn- Function for prefix allocation (default: uses HighContentionAllocator):node_keyspace- Custom node storage location:content_keyspace- Custom content storage location
@spec to_keyspace( directory(), opts :: [key_encoding: module(), value_encoding: module()] ) :: Bedrock.Keyspace.t()
Returns a Bedrock.Keyspace for this directory.
The keyspace can be used to store and retrieve data within this directory's keyspace.