Astarte.DataAccess.Config (astarte_data_access v1.0.2) View Source

This module helps the access to the runtime configuration of Astarte Data Access

Link to this section Summary

Functions

Discover nodes in the same cluster as specified in CASSANDRA_NODES. If your Cassandra instance is outside of your network, enabling the autodiscovery leads to connection failures. Defaults to false.

Discover nodes in the same cluster as specified in CASSANDRA_NODES. If your Cassandra instance is outside of your network, enabling the autodiscovery leads to connection failures. Defaults to false.

The password used to log into cassandra. Defaults to 'cassandra'.

The password used to log into cassandra. Defaults to 'cassandra'.

The username used to log into cassandra. Defaults to "cassandra".

The username used to log into cassandra. Defaults to "cassandra".

A list of {host, port} values of accessible Cassandra nodes in a cqex compliant format

A list of {host, port} values of accessible Cassandra nodes in a cqex compliant format

The number of connections to start for the pool, Defaults to 1.

The number of connections to start for the pool, Defaults to 1.

Preloads all variables in a namespace if supplied.

Puts the value to Astarte.DataAccess.Config.cqex_nodes/0. Optionally, receives the namespace.

Puts the value to Astarte.DataAccess.Config.pool_size/0. Optionally, receives the namespace.

Puts the value to Astarte.DataAccess.Config.ssl_ca_file/0. Optionally, receives the namespace.

Puts the value to Astarte.DataAccess.Config.ssl_custom_sni/0. Optionally, receives the namespace.

Puts the value to Astarte.DataAccess.Config.ssl_disable_sni/0. Optionally, receives the namespace.

Puts the value to Astarte.DataAccess.Config.ssl_enabled/0. Optionally, receives the namespace.

Puts the value to Astarte.DataAccess.Config.xandra_nodes/0. Optionally, receives the namespace.

Reloads the value for Astarte.DataAccess.Config.autodiscovery_enabled/0. Optionally, receives the namespace for the variable.

Reloads the value for Astarte.DataAccess.Config.cassandra_password/0. Optionally, receives the namespace for the variable.

Reloads the value for Astarte.DataAccess.Config.cassandra_username/0. Optionally, receives the namespace for the variable.

Reloads the value for Astarte.DataAccess.Config.cqex_nodes/0. Optionally, receives the namespace for the variable.

Reloads the value for Astarte.DataAccess.Config.pool_size/0. Optionally, receives the namespace for the variable.

Reloads the value for Astarte.DataAccess.Config.ssl_ca_file/0. Optionally, receives the namespace for the variable.

Reloads the value for Astarte.DataAccess.Config.ssl_custom_sni/0. Optionally, receives the namespace for the variable.

Reloads the value for Astarte.DataAccess.Config.ssl_disable_sni/0. Optionally, receives the namespace for the variable.

Reloads the value for Astarte.DataAccess.Config.ssl_enabled/0. Optionally, receives the namespace for the variable.

Reloads the value for Astarte.DataAccess.Config.xandra_nodes/0. Optionally, receives the namespace for the variable.

Specifies the certificates of the root Certificate Authorities to be trusted. When not specified, the bundled cURL certificate bundle will be used.

Specifies the certificates of the root Certificate Authorities to be trusted. When not specified, the bundled cURL certificate bundle will be used.

Specify the hostname to be used in TLS Server Name Indication extension. If not specified, the cassandra nodes will be used. This value is used only if Server Name Indication is enabled.

Specify the hostname to be used in TLS Server Name Indication extension. If not specified, the cassandra nodes will be used. This value is used only if Server Name Indication is enabled.

Disable Server Name Indication. Defaults to false.

Disable Server Name Indication. Defaults to false.

Enable SSL for Cassandra connections. Defaults to false.

Enable SSL for Cassandra connections. Defaults to false.

Creates a template for OS environment variables given a filename. Additionally, it can receive a list of options

Validates that all required variables are present. Returns :ok if they are, {:error, errors} if they are not. errors will be a list of all errors encountered while getting required variables.

Validates that all required variables are present. Returns :ok if they are, raises if they're not.

A list of host values of accessible Cassandra nodes formatted in the Xandra format

A list of host values of accessible Cassandra nodes formatted in the Xandra format

Link to this section Types

Specs

auth_options() :: {module(), [{String.t(), String.t()}]}

Specs

cqex_opts() ::
  {:ssl, ssl_options()} | {:auth, auth_options()} | {:keyspace, String.t()}

Specs

ssl_option() ::
  {:cacertfile, String.t()}
  | {:verify, :verify_peer}
  | {:server_name_indication, :disable | charlist()}
  | {:depth, integer()}

Specs

ssl_options() :: :none | [ssl_option()]

Link to this section Functions

Link to this function

autodiscovery_enabled(namespace \\ nil)

View Source

Specs

autodiscovery_enabled(Skogsra.Env.namespace()) ::
  {:ok, boolean()} | {:error, binary()}

Discover nodes in the same cluster as specified in CASSANDRA_NODES. If your Cassandra instance is outside of your network, enabling the autodiscovery leads to connection failures. Defaults to false.

Calling Astarte.DataAccess.Config.autodiscovery_enabled() will ensure the following:

  • Binding order: [:system, :config]
  • OS environment variable: "CASSANDRA_AUTODISCOVERY_ENABLED"
  • Type: :boolean
  • Default: false
  • Required: false
  • Cached: true
Link to this function

autodiscovery_enabled!(namespace \\ nil)

View Source

Specs

autodiscovery_enabled!(Skogsra.Env.namespace()) :: boolean() | no_return()

Discover nodes in the same cluster as specified in CASSANDRA_NODES. If your Cassandra instance is outside of your network, enabling the autodiscovery leads to connection failures. Defaults to false.

Bang version of Astarte.DataAccess.Config.autodiscovery_enabled/0 (fails on error). Optionally, receives the namespace for the variable.

Link to this function

cassandra_password(namespace \\ nil)

View Source

Specs

cassandra_password(Skogsra.Env.namespace()) ::
  {:ok, binary()} | {:error, binary()}

The password used to log into cassandra. Defaults to 'cassandra'.

Calling Astarte.DataAccess.Config.cassandra_password() will ensure the following:

  • Binding order: [:system, :config]
  • OS environment variable: "CASSANDRA_PASSWORD"
  • Type: :binary
  • Default: "cassandra"
  • Required: false
  • Cached: true
Link to this function

cassandra_password!(namespace \\ nil)

View Source

Specs

cassandra_password!(Skogsra.Env.namespace()) :: binary() | no_return()

The password used to log into cassandra. Defaults to 'cassandra'.

Bang version of Astarte.DataAccess.Config.cassandra_password/0 (fails on error). Optionally, receives the namespace for the variable.

Link to this function

cassandra_username(namespace \\ nil)

View Source

Specs

cassandra_username(Skogsra.Env.namespace()) ::
  {:ok, binary()} | {:error, binary()}

The username used to log into cassandra. Defaults to "cassandra".

Calling Astarte.DataAccess.Config.cassandra_username() will ensure the following:

  • Binding order: [:system, :config]
  • OS environment variable: "CASSANDRA_USERNAME"
  • Type: :binary
  • Default: "cassandra"
  • Required: false
  • Cached: true
Link to this function

cassandra_username!(namespace \\ nil)

View Source

Specs

cassandra_username!(Skogsra.Env.namespace()) :: binary() | no_return()

The username used to log into cassandra. Defaults to "cassandra".

Bang version of Astarte.DataAccess.Config.cassandra_username/0 (fails on error). Optionally, receives the namespace for the variable.

Link to this function

cqex_nodes(namespace \\ nil)

View Source

Specs

cqex_nodes(Skogsra.Env.namespace()) ::
  {:ok, Astarte.DataAccess.Config.CQExNodes.t()} | {:error, binary()}

A list of {host, port} values of accessible Cassandra nodes in a cqex compliant format

Calling Astarte.DataAccess.Config.cqex_nodes() will ensure the following:

  • Binding order: [:system, :config]
  • OS environment variable: "CASSANDRA_NODES"
  • Type: Astarte.DataAccess.Config.CQExNodes
  • Default: [{"localhost", 9042}]
  • Required: false
  • Cached: true
Link to this function

cqex_nodes!(namespace \\ nil)

View Source

Specs

cqex_nodes!(Skogsra.Env.namespace()) ::
  Astarte.DataAccess.Config.CQExNodes.t() | no_return()

A list of {host, port} values of accessible Cassandra nodes in a cqex compliant format

Bang version of Astarte.DataAccess.Config.cqex_nodes/0 (fails on error). Optionally, receives the namespace for the variable.

Specs

cqex_options!() :: [cqex_opts()]
Link to this function

pool_size(namespace \\ nil)

View Source

Specs

pool_size(Skogsra.Env.namespace()) :: {:ok, integer()} | {:error, binary()}

The number of connections to start for the pool, Defaults to 1.

Calling Astarte.DataAccess.Config.pool_size() will ensure the following:

  • Binding order: [:system, :config]
  • OS environment variable: "CASSANDRA_POOL_SIZE"
  • Type: :integer
  • Default: 1
  • Required: false
  • Cached: true
Link to this function

pool_size!(namespace \\ nil)

View Source

Specs

pool_size!(Skogsra.Env.namespace()) :: integer() | no_return()

The number of connections to start for the pool, Defaults to 1.

Bang version of Astarte.DataAccess.Config.pool_size/0 (fails on error). Optionally, receives the namespace for the variable.

Link to this function

preload(namespace \\ nil)

View Source

Specs

preload(Skogsra.Env.namespace()) :: :ok

Preloads all variables in a namespace if supplied.

Link to this function

put_autodiscovery_enabled(value, namespace \\ nil)

View Source

Specs

put_autodiscovery_enabled(boolean(), Skogsra.Env.namespace()) ::
  :ok | {:error, binary()}

Puts the value to Astarte.DataAccess.Config.autodiscovery_enabled/0. Optionally, receives the namespace.

Link to this function

put_cassandra_password(value, namespace \\ nil)

View Source

Specs

put_cassandra_password(binary(), Skogsra.Env.namespace()) ::
  :ok | {:error, binary()}

Puts the value to Astarte.DataAccess.Config.cassandra_password/0. Optionally, receives the namespace.

Link to this function

put_cassandra_username(value, namespace \\ nil)

View Source

Specs

put_cassandra_username(binary(), Skogsra.Env.namespace()) ::
  :ok | {:error, binary()}

Puts the value to Astarte.DataAccess.Config.cassandra_username/0. Optionally, receives the namespace.

Link to this function

put_cqex_nodes(value, namespace \\ nil)

View Source

Specs

put_cqex_nodes(Astarte.DataAccess.Config.CQExNodes.t(), Skogsra.Env.namespace()) ::
  :ok | {:error, binary()}

Puts the value to Astarte.DataAccess.Config.cqex_nodes/0. Optionally, receives the namespace.

Link to this function

put_pool_size(value, namespace \\ nil)

View Source

Specs

put_pool_size(integer(), Skogsra.Env.namespace()) :: :ok | {:error, binary()}

Puts the value to Astarte.DataAccess.Config.pool_size/0. Optionally, receives the namespace.

Link to this function

put_ssl_ca_file(value, namespace \\ nil)

View Source

Specs

put_ssl_ca_file(binary(), Skogsra.Env.namespace()) :: :ok | {:error, binary()}

Puts the value to Astarte.DataAccess.Config.ssl_ca_file/0. Optionally, receives the namespace.

Link to this function

put_ssl_custom_sni(value, namespace \\ nil)

View Source

Specs

put_ssl_custom_sni(nil | binary(), Skogsra.Env.namespace()) ::
  :ok | {:error, binary()}

Puts the value to Astarte.DataAccess.Config.ssl_custom_sni/0. Optionally, receives the namespace.

Link to this function

put_ssl_disable_sni(value, namespace \\ nil)

View Source

Specs

put_ssl_disable_sni(boolean(), Skogsra.Env.namespace()) ::
  :ok | {:error, binary()}

Puts the value to Astarte.DataAccess.Config.ssl_disable_sni/0. Optionally, receives the namespace.

Link to this function

put_ssl_enabled(value, namespace \\ nil)

View Source

Specs

put_ssl_enabled(boolean(), Skogsra.Env.namespace()) :: :ok | {:error, binary()}

Puts the value to Astarte.DataAccess.Config.ssl_enabled/0. Optionally, receives the namespace.

Link to this function

put_xandra_nodes(value, namespace \\ nil)

View Source

Specs

put_xandra_nodes(
  Astarte.DataAccess.Config.XandraNodes.t(),
  Skogsra.Env.namespace()
) :: :ok | {:error, binary()}

Puts the value to Astarte.DataAccess.Config.xandra_nodes/0. Optionally, receives the namespace.

Link to this function

reload_autodiscovery_enabled(namespace \\ nil)

View Source

Specs

reload_autodiscovery_enabled(Skogsra.Env.namespace()) ::
  {:ok, boolean()} | {:error, binary()}

Reloads the value for Astarte.DataAccess.Config.autodiscovery_enabled/0. Optionally, receives the namespace for the variable.

Link to this function

reload_cassandra_password(namespace \\ nil)

View Source

Specs

reload_cassandra_password(Skogsra.Env.namespace()) ::
  {:ok, binary()} | {:error, binary()}

Reloads the value for Astarte.DataAccess.Config.cassandra_password/0. Optionally, receives the namespace for the variable.

Link to this function

reload_cassandra_username(namespace \\ nil)

View Source

Specs

reload_cassandra_username(Skogsra.Env.namespace()) ::
  {:ok, binary()} | {:error, binary()}

Reloads the value for Astarte.DataAccess.Config.cassandra_username/0. Optionally, receives the namespace for the variable.

Link to this function

reload_cqex_nodes(namespace \\ nil)

View Source

Specs

reload_cqex_nodes(Skogsra.Env.namespace()) ::
  {:ok, Astarte.DataAccess.Config.CQExNodes.t()} | {:error, binary()}

Reloads the value for Astarte.DataAccess.Config.cqex_nodes/0. Optionally, receives the namespace for the variable.

Link to this function

reload_pool_size(namespace \\ nil)

View Source

Specs

reload_pool_size(Skogsra.Env.namespace()) ::
  {:ok, integer()} | {:error, binary()}

Reloads the value for Astarte.DataAccess.Config.pool_size/0. Optionally, receives the namespace for the variable.

Link to this function

reload_ssl_ca_file(namespace \\ nil)

View Source

Specs

reload_ssl_ca_file(Skogsra.Env.namespace()) ::
  {:ok, binary()} | {:error, binary()}

Reloads the value for Astarte.DataAccess.Config.ssl_ca_file/0. Optionally, receives the namespace for the variable.

Link to this function

reload_ssl_custom_sni(namespace \\ nil)

View Source

Specs

reload_ssl_custom_sni(Skogsra.Env.namespace()) ::
  {:ok, nil | binary()} | {:error, binary()}

Reloads the value for Astarte.DataAccess.Config.ssl_custom_sni/0. Optionally, receives the namespace for the variable.

Link to this function

reload_ssl_disable_sni(namespace \\ nil)

View Source

Specs

reload_ssl_disable_sni(Skogsra.Env.namespace()) ::
  {:ok, boolean()} | {:error, binary()}

Reloads the value for Astarte.DataAccess.Config.ssl_disable_sni/0. Optionally, receives the namespace for the variable.

Link to this function

reload_ssl_enabled(namespace \\ nil)

View Source

Specs

reload_ssl_enabled(Skogsra.Env.namespace()) ::
  {:ok, boolean()} | {:error, binary()}

Reloads the value for Astarte.DataAccess.Config.ssl_enabled/0. Optionally, receives the namespace for the variable.

Link to this function

reload_xandra_nodes(namespace \\ nil)

View Source

Specs

reload_xandra_nodes(Skogsra.Env.namespace()) ::
  {:ok, Astarte.DataAccess.Config.XandraNodes.t()} | {:error, binary()}

Reloads the value for Astarte.DataAccess.Config.xandra_nodes/0. Optionally, receives the namespace for the variable.

Link to this function

ssl_ca_file(namespace \\ nil)

View Source

Specs

ssl_ca_file(Skogsra.Env.namespace()) :: {:ok, binary()} | {:error, binary()}

Specifies the certificates of the root Certificate Authorities to be trusted. When not specified, the bundled cURL certificate bundle will be used.

Calling Astarte.DataAccess.Config.ssl_ca_file() will ensure the following:

  • Binding order: [:system, :config]
  • OS environment variable: "CASSANDRA_SSL_CA_FILE"
  • Type: :binary
  • Default: "/home/davide/Ispirata/Astarte/astarte_data_access/_build/dev/lib/castore/priv/cacerts.pem"
  • Required: false
  • Cached: true
Link to this function

ssl_ca_file!(namespace \\ nil)

View Source

Specs

ssl_ca_file!(Skogsra.Env.namespace()) :: binary() | no_return()

Specifies the certificates of the root Certificate Authorities to be trusted. When not specified, the bundled cURL certificate bundle will be used.

Bang version of Astarte.DataAccess.Config.ssl_ca_file/0 (fails on error). Optionally, receives the namespace for the variable.

Link to this function

ssl_custom_sni(namespace \\ nil)

View Source

Specs

ssl_custom_sni(Skogsra.Env.namespace()) ::
  {:ok, nil | binary()} | {:error, binary()}

Specify the hostname to be used in TLS Server Name Indication extension. If not specified, the cassandra nodes will be used. This value is used only if Server Name Indication is enabled.

Calling Astarte.DataAccess.Config.ssl_custom_sni() will ensure the following:

  • Binding order: [:system, :config]
  • OS environment variable: "CASSANDRA_SSL_CUSTOM_SNI"
  • Type: :binary
  • Default: nil
  • Required: false
  • Cached: true
Link to this function

ssl_custom_sni!(namespace \\ nil)

View Source

Specs

ssl_custom_sni!(Skogsra.Env.namespace()) :: (nil | binary()) | no_return()

Specify the hostname to be used in TLS Server Name Indication extension. If not specified, the cassandra nodes will be used. This value is used only if Server Name Indication is enabled.

Bang version of Astarte.DataAccess.Config.ssl_custom_sni/0 (fails on error). Optionally, receives the namespace for the variable.

Link to this function

ssl_disable_sni(namespace \\ nil)

View Source

Specs

ssl_disable_sni(Skogsra.Env.namespace()) ::
  {:ok, boolean()} | {:error, binary()}

Disable Server Name Indication. Defaults to false.

Calling Astarte.DataAccess.Config.ssl_disable_sni() will ensure the following:

  • Binding order: [:system, :config]
  • OS environment variable: "CASSANDRA_SSL_DISABLE_SNI"
  • Type: :boolean
  • Default: false
  • Required: false
  • Cached: true
Link to this function

ssl_disable_sni!(namespace \\ nil)

View Source

Specs

ssl_disable_sni!(Skogsra.Env.namespace()) :: boolean() | no_return()

Disable Server Name Indication. Defaults to false.

Bang version of Astarte.DataAccess.Config.ssl_disable_sni/0 (fails on error). Optionally, receives the namespace for the variable.

Link to this function

ssl_enabled(namespace \\ nil)

View Source

Specs

ssl_enabled(Skogsra.Env.namespace()) :: {:ok, boolean()} | {:error, binary()}

Enable SSL for Cassandra connections. Defaults to false.

Calling Astarte.DataAccess.Config.ssl_enabled() will ensure the following:

  • Binding order: [:system, :config]
  • OS environment variable: "CASSANDRA_SSL_ENABLED"
  • Type: :boolean
  • Default: false
  • Required: false
  • Cached: true
Link to this function

ssl_enabled!(namespace \\ nil)

View Source

Specs

ssl_enabled!(Skogsra.Env.namespace()) :: boolean() | no_return()

Enable SSL for Cassandra connections. Defaults to false.

Bang version of Astarte.DataAccess.Config.ssl_enabled/0 (fails on error). Optionally, receives the namespace for the variable.

Link to this function

template(filename, options \\ [])

View Source

Specs

template(Path.t(), keyword()) :: :ok | {:error, File.posix()}

Creates a template for OS environment variables given a filename. Additionally, it can receive a list of options:

  • type: What kind of file it will generate (:elixir, :unix, :windows).
  • namespace: Namespace for the variables.
Link to this function

validate(namespace \\ nil)

View Source

Specs

validate(Skogsra.Env.namespace()) :: :ok | {:error, [binary()]}

Validates that all required variables are present. Returns :ok if they are, {:error, errors} if they are not. errors will be a list of all errors encountered while getting required variables.

It is possible to provide a namespace as argument (defaults to nil).

Link to this function

validate!(namespace \\ nil)

View Source

Specs

validate!(Skogsra.Env.namespace()) :: :ok | no_return()

Validates that all required variables are present. Returns :ok if they are, raises if they're not.

It is possible to provide a namespace as argument (defaults to nil).

Link to this function

xandra_nodes(namespace \\ nil)

View Source

Specs

xandra_nodes(Skogsra.Env.namespace()) ::
  {:ok, Astarte.DataAccess.Config.XandraNodes.t()} | {:error, binary()}

A list of host values of accessible Cassandra nodes formatted in the Xandra format

Calling Astarte.DataAccess.Config.xandra_nodes() will ensure the following:

  • Binding order: [:system, :config]
  • OS environment variable: "CASSANDRA_NODES"
  • Type: Astarte.DataAccess.Config.XandraNodes
  • Default: ["localhost:9042"]
  • Required: false
  • Cached: true
Link to this function

xandra_nodes!(namespace \\ nil)

View Source

Specs

xandra_nodes!(Skogsra.Env.namespace()) ::
  Astarte.DataAccess.Config.XandraNodes.t() | no_return()

A list of host values of accessible Cassandra nodes formatted in the Xandra format

Bang version of Astarte.DataAccess.Config.xandra_nodes/0 (fails on error). Optionally, receives the namespace for the variable.

Specs

xandra_options!() :: Xandra.start_options()