tree: 3fe21c574586fd18ef0bca5a2499b1e74713007d
  1. lib/
  2. native/
  3. test/
  4. .formatter.exs
  5. .gitignore
  6. mix.exs
  7. mix.lock
  8. README.md
bindings/elixir/README.md

Fluss Elixir Client

Elixir client for Apache Fluss (Incubating), built on the official Rust client via Rustler NIFs.

Currently supports log tables (append + scan). Primary key (KV) table support is planned.

Requirements

  • Elixir >= 1.15
  • Rust stable toolchain (for compiling the NIF)

Quick Start

config = Fluss.Config.new("localhost:9123")
conn = Fluss.Connection.new!(config)
admin = Fluss.Admin.new!(conn)

schema =
  Fluss.Schema.build()
  |> Fluss.Schema.column("ts", :bigint)
  |> Fluss.Schema.column("message", :string)
  |> Fluss.Schema.build!()

:ok = Fluss.Admin.create_table(admin, "my_db", "events", Fluss.TableDescriptor.new!(schema))

table = Fluss.Table.get!(conn, "my_db", "events")
writer = Fluss.AppendWriter.new!(table)
Fluss.AppendWriter.append(writer, [1_700_000_000, "hello"])
:ok = Fluss.AppendWriter.flush(writer)

scanner = Fluss.LogScanner.new!(table)
:ok = Fluss.LogScanner.subscribe(scanner, 0, Fluss.earliest_offset())
:ok = Fluss.LogScanner.poll(scanner, 5_000)

receive do
  {:fluss_records, records} ->
    for record <- records, do: IO.inspect(record[:row])
end

Data Types

Simple: :boolean, :tinyint, :smallint, :int, :bigint, :float, :double, :string, :bytes, :date, :time, :timestamp, :timestamp_ltz

Parameterized: {:decimal, precision, scale}, {:char, length}, {:binary, length}

Development

cd bindings/elixir
mix test                        # unit tests
mix test --include integration  # starts Docker cluster

Set FLUSS_BOOTSTRAP_SERVERS to use an existing cluster.

License

Apache License 2.0