View Source Instream.Connection behaviour (Instream v2.0.0-rc.0)
Defines a connection to an InfluxDB instance.
Connection Definition
defmodule MyConnection do
use Instream.Connection, otp_app: :my_app
endThis connection will fetch its configuration from the application environment
as defined by :otp_app. As an alternative you can define the configuration
in the module definition itself:
defmodule MyConnection do
use Instream.Connection,
config: [
version: :v1,
host: "influxdb.example.com",
scheme: "http"
]
endBoth inline and :otp_app configuration can be mixed. In this case the
application configuration will overwrite any inline values.
For more information on how to configure your connection please refer to
the documentation of Instream.Connection.Config.
InfluxDB version
By default a connection module will expect to communicate with an
InfluxDB 1.x server (version: :v1). Configure version: :v2 if you
are running an InfluxDB 2.x server.
Link to this section Summary
Callbacks
Returns a supervisable connection child_spec.
Returns the connection configuration.
Pings the connection server.
Executes a reading query.
Checks the status of the connection server.
Determines the version of the connection server.
Executes a writing query.
Link to this section Types
Specs
e_version_mismatch() :: {:error, :version_mismatch}
Specs
log_entry() :: Instream.Log.PingEntry.t() | Instream.Log.QueryEntry.t() | Instream.Log.StatusEntry.t() | Instream.Log.WriteEntry.t()
Specs
precision() :: :hour | :minute | :second | :millisecond | :microsecond | :nanosecond | :rfc3339
Link to this section Callbacks
Specs
child_spec(_ignored :: term()) :: Supervisor.child_spec()
Returns a supervisable connection child_spec.
Specs
Returns the connection configuration.
Specs
ping(opts :: Keyword.t()) :: :pong | :error
Pings the connection server.
Specs
Executes a reading query.
Options:
database: use a database differing from the connection config for readingmethod: whether to use a:getor:postrequestorg: use an organization differing from the connection config for readingprecision: return data with a "precision" other than:rfc3339
Specs
status(opts :: Keyword.t()) :: :ok | :error | e_version_mismatch()
Checks the status of the connection server.
Only available with InfluxDB v1.x connections.
Specs
Determines the version of the connection server.
If the version if undetectable (no header returned) it will be
reported as "unknown". If the host is unreachable or an error occurred
the response will be :error.
Specs
Executes a writing query.
Usable options depend on the writer module configured.