ExeQute.Introspect
(exe_qute v0.1.2)
Copy Markdown
Live introspection of a KDB+ instance's namespaces, tables, functions, and variables.
All four functions are available as top-level delegates on ExeQute — that is
the recommended entry point for most callers:
{:ok, namespaces} = ExeQute.namespaces(conn)
{:ok, tables} = ExeQute.tables(conn, ".myns")
{:ok, fns} = ExeQute.functions(conn, ".myns")
{:ok, vars} = ExeQute.variables(conn, ".myns")See ExeQute.namespaces/1, ExeQute.tables/2, ExeQute.functions/2, and
ExeQute.variables/2 for full documentation including examples.
Caching
Results are cached inside the connection process after the first call. Repeated calls for the same namespace key are free — no round-trip to KDB+. The cache is scoped to the connection and cleared automatically when the connection stops.
Call ExeQute.refresh_introspection/1 to invalidate the cache and force a
fresh fetch, for example after deploying new q code:
ExeQute.refresh_introspection(conn)Typical workflow
{:ok, conn} = ExeQute.connect(host: "kdb-host", port: 5010)
{:ok, namespaces} = ExeQute.namespaces(conn)
# [".myns", ".feed", ".q", ".Q", ".h"]
{:ok, tables} = ExeQute.tables(conn, ".myns")
# ["trade", "quote"]
{:ok, fns} = ExeQute.functions(conn, ".myns")
# [%{"name" => ".myns.getquotes", "params" => ["sym", "date"], "body" => "{...}"}]
name = hd(fns)["name"]
params = hd(fns)["params"]
# Call it with typed arguments:
{:ok, result} = ExeQute.query(conn, name, ["EUR/USD", ~D[2024-01-01]])
Summary
Functions
Lists functions in a namespace along with their parameter names.
Lists all namespaces defined on the KDB+ instance.
Lists table names in a namespace.
Lists variable names in a namespace.
Functions
Lists functions in a namespace along with their parameter names.
Pass a namespace string such as ".myns" or omit/nil for the root namespace.
Returns a list of maps with:
"name"— fully qualified function name"params"— list of parameter name strings; empty for zero-arity or non-lambda values"body"— function source code as a string; empty string for non-lambda values
Examples
{:ok, fns} = ExeQute.functions(conn)
{:ok, fns} = ExeQute.functions(conn, ".myns")
#=> {:ok, [
#=> %{"name" => ".myns.getquotes", "params" => ["sym", "start", "end"], "body" => "{[sym;start;end] ...}"},
#=> %{"name" => ".myns.upd", "params" => ["t", "x"], "body" => "{[t;x] ...}"},
#=> %{"name" => ".myns.init", "params" => [], "body" => "{[] ...}"},
#=> ]}
Lists all namespaces defined on the KDB+ instance.
Returns namespace names prefixed with . (e.g. ".myns", ".q", ".Q").
Examples
{:ok, ns} = ExeQute.namespaces(conn)
#=> {:ok, [".q", ".Q", ".h", ".myns"]}
Lists table names in a namespace.
Pass a namespace string such as ".myns" or omit/nil for the root namespace.
Examples
{:ok, tables} = ExeQute.tables(conn)
{:ok, tables} = ExeQute.tables(conn, ".myns")
#=> {:ok, ["trade", "quote"]}
Lists variable names in a namespace.
Pass a namespace string such as ".myns" or omit/nil for the root namespace.
Examples
{:ok, vars} = ExeQute.variables(conn)
{:ok, vars} = ExeQute.variables(conn, ".myns")
#=> {:ok, ["bidSize", "askSize"]}