Instream v0.9.0 Instream.Connection behaviour

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,
  hosts:    [ "primary.example.com", "secondary.example.com" ],
  password: "pass",
  pool:     [ max_overflow: 10, size: 5 ],
  port:     8086,
  scheme:   "http",
  username: "root"

Summary

Callbacks

Returns the (internal) pool module

Returns a supervisable pool child_spec

Returns the connection configuration

Executes a query

Executes a reading query

Executes a writing query

Types

Callbacks

__pool__()

Specs

__pool__ :: module

Returns the (internal) pool module.

child_spec()

Specs

child_spec :: Supervisor.Spec.spec

Returns a supervisable pool child_spec.

config()

Specs

config :: Keyword.t

Returns the connection configuration.

execute(query, opts)

Specs

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.

query(query, opts)

Specs

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.

write(payload, opts)

Specs

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.