Instream v0.18.0 Instream.Connection behaviour View Source

Connection (pool) definition.

All database connections will be made using a user-defined extension of this module.

Example Module

defmodule MyConnection do
  use Instream.Connection, otp_app: :my_application
end

Example Configuration

config :my_application, MyConnection,
  auth:      [ method: :basic, username: "root", password: "root" ]
  host:      "influxdb.example.com",
  http_opts: [ insecure: true, proxy: "http://company.proxy" ],
  loggers:   [{ LogModule, :log_fun, [ :additional, :args ] }],
  password:  "pass",
  pool:      [ max_overflow: 10, size: 5 ],
  port:      8086,
  scheme:    "http",
  username:  "user"

Link to this section Summary

Callbacks

Sends a log entry to all configured loggers

Returns the (internal) pool module

Returns a supervisable connection child_spec

Returns the connection configuration

Executes a query

Pings a server

Executes a reading query

Checks the status of a connection

Executes a writing query

Link to this section Types

Link to this section Callbacks

Link to this callback __log__(log_entry) View Source
__log__(log_entry()) :: log_entry()

Sends a log entry to all configured loggers.

Returns the (internal) pool module.

Link to this callback child_spec(_ignored) View Source
child_spec(_ignored :: term()) :: Supervisor.Spec.spec()

Returns a supervisable connection child_spec.

Link to this callback config(keys) View Source
config(keys :: [term(), ...]) :: Keyword.t()

Returns the connection configuration.

Link to this callback execute(query, opts) View Source
execute(query :: query_type(), opts :: Keyword.t()) :: any()

Executes a query.

Passing [async: true] in the options always returns :ok. The command will be executed asynchronously.

Link to this callback ping(host, opts) View Source
ping(host :: String.t(), opts :: Keyword.t()) :: :pong | :error

Pings a server.

By default the first server in your connection configuration will be pinged.

The server passed does not necessarily need to belong to your connection. Only the connection details (scheme, port, …) will be used to determine the exact url to send the ping request to.

Link to this callback query(query, opts) View Source
query(query :: String.t(), opts :: Keyword.t()) :: any()

Executes a reading query.

See Instream.Connection.execute/2 and Instream.Data.Read.query/2 for a complete list of available options.

Link to this callback status(opts) View Source
status(opts :: Keyword.t()) :: :ok | :error

Checks the status of a connection.

Link to this callback write(payload, opts) View Source
write(payload :: map() | [map()], opts :: Keyword.t()) :: any()

Executes a writing query.

See Instream.Connection.execute/2 and Instream.Data.Write.query/2 for a complete list of available options.