QuackDB.Server (quackdb v0.5.3)

Copy Markdown View Source

Supervises a local DuckDB Quack server process with MuonTrap.

This is a convenience for local development, tests, demos, and notebooks. It starts the external duckdb executable and serves DuckDB's Quack HTTP protocol. It is not an embedded DuckDB driver and is not required when your Quack server runs elsewhere.

children =
  QuackDB.Server.child_specs(
    server: [name: MyApp.DuckDB, duckdb: :managed, endpoint: "quack:localhost:9494"],
    client: [name: MyApp.QuackDB, pool_size: 5]
  )

Use duckdb: :managed to download and cache DuckDB's official CLI binary via QuackDB.Binary. Pass duckdb: "/path/to/duckdb" or set QUACKDB_BINARY_PATH when you want to provide the executable yourself.

child_specs/1 generates one shared random token when neither side provides :token, then injects the same token and URI into the server and client specs.

By default the server runs DuckDB directly under MuonTrap with -interactive so the process stays alive after quack_serve/2 starts:

duckdb :memory: -csv -noheader -interactive -init /dev/null -cmd "LOAD quack; ..."

Startup waits until the Quack endpoint is ready. For the default DuckDB CLI command, readiness is detected from the quack_serve/2 result row printed to stdout. :poll_interval is only the fallback probe interval for custom daemon output handling or custom commands that do not expose that row.

Summary

Types

option()

@type option() ::
  {:name, GenServer.name()}
  | {:duckdb, String.t() | :managed}
  | {:duckdb_options, keyword()}
  | {:database, String.t()}
  | {:endpoint, String.t()}
  | {:uri, String.t()}
  | {:token, String.t()}
  | {:load_quack?, boolean()}
  | {:boot_sql, String.t()}
  | {:settings, keyword(QuackDB.SQL.parameter())}
  | {:global_settings, keyword(QuackDB.SQL.parameter())}
  | {:recovery_mode, :no_wal_writes | String.t()}
  | {:attach_as, atom() | String.t()}
  | {:wait, boolean()}
  | {:wait_timeout, timeout()}
  | {:poll_interval, pos_integer()}
  | {:daemon_options, Keyword.t()}
  | {:daemon_command, {String.t(), [String.t()]}}

Functions

child_spec(init_arg)

@spec child_spec([option()]) :: Supervisor.child_spec()

Returns a specification to start this module under a supervisor.

See Supervisor.

child_specs(options \\ [])

@spec child_specs(keyword()) :: [Supervisor.child_spec()]

info(server)

@spec info(GenServer.server()) :: map()

os_pid(server)

@spec os_pid(GenServer.server()) :: non_neg_integer() | :error

start_link(options \\ [])

@spec start_link([option()]) :: GenServer.on_start()

statistics(server)

@spec statistics(GenServer.server()) :: map()

token(server)

@spec token(GenServer.server()) :: String.t()

uri(server)

@spec uri(GenServer.server()) :: String.t()