AshScylla.Repo behaviour (AshScylla v0.8.0)

Copy Markdown View Source

Configuration module for AshScylla using direct Xandra connections.

Usage

defmodule MyApp.Repo do
  use AshScylla.Repo,
    otp_app: :my_app
end

Then configure it in config/config.exs:

config :my_app, MyApp.Repo,
  nodes: ["127.0.0.1:9042"],
  keyspace: "my_app_dev"

Adding to your supervision tree

children = [
  MyApp.Repo,
  # ...
]

Options

  • :nodes - List of ScyllaDB/Cassandra nodes to connect to
  • :keyspace - The keyspace to use
  • :connect_timeout - TCP connection timeout in ms (default: 5000)

Summary

Functions

Converts repo config to Xandra connection options.

Callbacks

child_spec(keyword)

@callback child_spec(keyword()) :: Supervisor.child_spec()

config()

@callback config() :: keyword()

connection()

@callback connection() :: AshScylla.Connection.t() | nil

create_keyspace(arg1, keyword)

@callback create_keyspace(
  String.t() | nil,
  keyword()
) :: {:ok, term()} | {:error, term()}

drop_keyspace(arg1)

@callback drop_keyspace(String.t() | nil) :: {:ok, term()} | {:error, term()}

keyspace()

@callback keyspace() :: String.t() | nil

nodes()

@callback nodes() :: [String.t()]

prepare(t, keyword)

@callback prepare(
  String.t(),
  keyword()
) :: {:ok, Xandra.Prepared.t()} | {:error, term()}

prepare!(t, keyword)

@callback prepare!(
  String.t(),
  keyword()
) :: Xandra.Prepared.t() | no_return()

query(t, list, keyword)

@callback query(String.t(), list(), keyword()) :: {:ok, term()} | {:error, term()}

query!(t, list, keyword)

@callback query!(String.t(), list(), keyword()) :: term() | no_return()

Functions

config_to_conn_opts(repo_module)

@spec config_to_conn_opts(module()) :: keyword()

Converts repo config to Xandra connection options.