Aerospike Driver

aerospike_driver is an OTP-native Aerospike client for Elixir. It provides a supervised cluster runtime, partition-aware routing, pooled TCP/TLS connections, and a public API for records, batch commands, scans, queries, CDTs, expressions, UDFs, security administration, and transactions.

The library is still pre-1.0, so the README calls out current boundaries rather than presenting the package as complete parity with every official Aerospike client.

Installation

Add aerospike_driver to your dependencies:

def deps do
  [
    {:aerospike_driver, "~> 0.3.0"}
  ]
end

Quick Start

Start a local Aerospike Community Edition node from this repository:

docker compose up -d

Define an application Repo module:

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

Configure and supervise it from your application:

# config/config.exs
config :my_app, MyApp.Repo,
  transport: Aerospike.Transport.Tcp,
  hosts: ["127.0.0.1:3000"],
  namespaces: ["test"],
  pool_size: 2

# lib/my_app/application.ex
children = [
  MyApp.Repo
]

Then write and read records without repeating the cluster name:

key = MyApp.Repo.key("test", "demo", "user:1")

{:ok, _meta} =
  MyApp.Repo.put(key, %{
    "name" => "Ada",
    "visits" => 1
  })

{:ok, record} = MyApp.Repo.get(key)
%{"name" => "Ada", "visits" => 1} = record.bins

Required startup options are :transport, :hosts, and :namespaces. The Repo uses its module name as the default cluster name; pass :name to use Aerospike.Repo when you need a different registered name. Startup also accepts cluster discovery and auth options such as :cluster_name, :seed_only_cluster, :application_id, :auth_mode, :login_timeout_ms, and :min_connections_per_node.

Startup validation runs synchronously through the underlying Aerospike.start_link/1, so malformed cluster, retry, pool, auth, and transport options fail before the runtime is published.

Use Aerospike.Cluster.ready?(MyApp.Repo.conn()) when your application wants to wait until the first cluster view is available for routing.

What It Supports

The canonical low-level public entry point is Aerospike. Applications can define a thin Aerospike.Repo module to bind that API to one supervised cluster. The current surface includes:

Typed data helpers are available for keys, records, errors, geo values, pages, partition filters, UDF tasks, index tasks, execution tasks, batch results, and transaction handles.

Runtime Model

The client starts a supervised cluster per configured :name. Internally, that cluster owns node discovery, partition maps, per-node connection pools, retry budgets, circuit-breaker state, and transaction tracking. Most applications should define a Repo module as their boundary:

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

The Repo is a thin facade over one cluster. It does not perform schema mapping, changeset validation, or object reflection. Lower-level code can call the registered cluster directly:

Aerospike.get(:aerospike, key)
Aerospike.query_all(:aerospike, query)
Aerospike.transaction(:aerospike, fn txn -> ... end)

Telemetry events are emitted under the [:aerospike, ...] prefix. Use Aerospike.Telemetry.handler_events/0 as the subscription source instead of copying event names into your application.

Guides

Use these guides for task-oriented examples:

Current Boundaries

This library is still pre-1.0. The implemented surface is broad, but it is not yet a promise of complete Aerospike client parity.

Important current boundaries:

See the module docs and guides for command-specific options and return shapes. See the CHANGELOG for release history.

Local Development

Run commands from this repository directory:

mix test
mix validate

The repo also provides profile-aware Make targets:

make test PROFILE=unit
make test PROFILE=ce
make test PROFILE=cluster
make test PROFILE=enterprise
make coverage PROFILE=unit
make validate

Live integration profiles use this repository's docker-compose.yml:

make deps PROFILE=ce
make deps PROFILE=cluster
make deps PROFILE=enterprise

For package docs, ExDoc uses this README as the Overview page and groups the Markdown files under guides/ as task-focused guides.