Boltx (Boltx v0.0.4)

Bolt driver for Elixir.

Summary

Types

The basic authentication scheme relies on traditional username and password

Types

Link to this type

basic_auth()

@type basic_auth() :: {:username, String.t()} | {:password, String.t() | nil}

The basic authentication scheme relies on traditional username and password

  • :username - Username (default: BOLT_USER env variable)

  • :password - Password (default: BOLT_PWD env variable, then nil)

@type conn() :: DBConnection.conn()
@type option() :: %{
  bookmarks: list(),
  mode: String.t(),
  db: String.t() | nil,
  tx_metadata: map() | nil
}
Link to this type

start_option()

@type start_option() ::
  {:uri, String.t()}
  | {:hostname, String.t()}
  | {:port, :inet.port_number()}
  | {:scheme, :inet.port_number()}
  | {:versions, [float()]}
  | {:auth, basic_auth()}
  | {:user_agent, String.t()}
  | {:notifications_minimum_severity, String.t()}
  | {:notifications_disabled_categories, [String.t()]}
  | {:ssl, boolean()}
  | {:ssl_opts, [:ssl.tls_client_option()]}
  | {:connect_timeout, timeout()}
  | {:socket_options, [:gen_tcp.connect_option()]}
  | DBConnection.start_option()

Functions

Link to this function

child_spec(options)

@spec child_spec([start_option()]) :: :supervisor.child_spec()

Returns a supervisor child specification for a DBConnection pool.

Link to this function

query(conn, statement, params \\ %{}, opts \\ [])

Link to this function

query!(conn, statement, params \\ %{}, opts \\ [])

Link to this function

query_many(conn, statement, params \\ %{}, opts \\ [])

Link to this function

query_many!(conn, statement, params \\ %{}, opts \\ [])

Link to this function

rollback(conn, reason)

@spec rollback(DBConnection.t(), any()) :: no_return()

See DBConnection.rollback/2.

Link to this function

start_link(options)

@spec start_link([start_option()]) :: {:ok, pid()} | {:error, Boltx.Error.t()}

Starts the connection process and connects to a Bolt/Neo4j server.

Options

  • :uri - Connection URI. The uri configuration takes priority over the hostname, port, and scheme options. URI has the form: <SCHEME>://<HOST>[:<PORT>[?policy=<POLICY-NAME>]]

  • :hostname - Server hostname (default: BOLT_HOST env variable, then "localhost")

  • :port - Server port (default: BOLT_TCP_PORT env variable, then 7687)

  • :scheme - Is one among neo4j, neo4j+s, neo4j+ssc, bolt, bolt+s, bolt+ssc (default: bolt+s).

  • :versions - List of bolt versions you want to be negotiated with the server.

  • :auth - The basic authentication scheme

  • :user_agent - Optionally override the default user agent name. (Default: 'boltx/<version>')

  • :notifications_minimum_severity - Set the minimum severity for notifications the server should send to the client. Disabling severities allows the server to skip analysis for those, which can speed up query execution. (default: nil) New in neo4j v5.7 and Bolt v5.2

  • :notifications_disabled_categories - Set categories of notifications the server should not send to the client. Disabling categories allows the server to skip analysis for those, which can speed up query execution. (default: nil) New in neo4j v5.7 and Bolt v5.2

  • :connect_timeout - Socket connect timeout in milliseconds (default: 15_000)

  • :ssl - Set to true if SSL should be used (default: true)

  • :ssl_opts - A list of SSL options, see :ssl.connect/2 (default: [verify: :verify_none])

The given options are passed down to DBConnection, some of the most commonly used ones are documented below:

  • :after_connect - A function to run after the connection has been established, either a 1-arity fun, a {module, function, args} tuple, or nil (default: nil)

  • :pool - The pool module to use, defaults to built-in pool provided by DBconnection

  • :pool_size - The size of the pool

Link to this function

transaction(conn, fun, opts \\ [], extra_parameters \\ %{})

@spec transaction(
  conn(),
  (DBConnection.t() -> result),
  [DBConnection.option()],
  option()
) ::
  {:ok, result} | {:error, any()}
when result: var