realbook v0.2.1 Realbook.Adapters.Api behaviour View Source

common interface for communications adapters between the local machine and the remote deployment target.

All realbook command macros adapt this interface to perform the relevant commands.

For example code, see:

Link to this section Summary

Types

A token that represents the remote deployment target.

allows you to select a stored key for content or file name

Callbacks

appends a binary or a file to the remote server.

connects into the remote target and produces a conn/0 token.

executes a unix command on the remote target.

sends a binary or a file to the remote server.

Link to this section Types

Specs

conn() :: any()

A token that represents the remote deployment target.

Such a token will be provided to the adapter functions as their first parameter. Produced by connect/1

Specs

variable_key() :: atom()

allows you to select a stored key for content or file name

Link to this section Callbacks

Link to this callback

append(conn, arg2, arg3, options)

View Source

Specs

append(conn(), binary() | Enumerable.t(), Path.t(), options :: keyword()) ::
  :ok | {:error, :file.posix()}

appends a binary or a file to the remote server.

NB: options might take the :sudo options, which should be filtered prior to sending the contents.

Specs

connect(options :: keyword()) :: {:ok, conn()} | {:error, term()}

connects into the remote target and produces a conn/0 token.

NB: for Realbook.Adapters.SSH the host parameter will live in this variable.

Link to this callback

run(conn, arg2, options)

View Source

Specs

run(conn(), String.t(), options :: keyword()) ::
  {:ok, String.t(), non_neg_integer()} | {:error, String.t() | :file.posix()}

executes a unix command on the remote target.

Warning:

this may or may not support piping operations, depending on the underlying implementation. The guidelines for running pipes may change in the future.

Link to this callback

send(conn, arg2, arg3, options)

View Source

Specs

send(conn(), binary() | Enumerable.t(), Path.t(), options :: keyword()) ::
  :ok | {:error, :file.posix()}

sends a binary or a file to the remote server.

NB: options might take the :sudo options, which should be filtered prior to sending the contents.