librarian v0.1.2 SSH.Stream View Source

Defines an SSH.Stream struct returned by SSH.stream!/3, as well as key functions that are involved in accessing the ssh data from the stream struct.

Like IO.Stream, an SSH stream has side effects. Any given time you use it, the contents returned are likely to be different.

Link to this section Summary

Types

ssh protocol stream control messages

binary data sent over the server's standard out (0) or standard error (1)

messages that the local client can use to send streaming content

a lambda that acts on channel data and convert it to stream tokens

all messages that are blocked by the stream control loop.

the default tokens that can be sent for stream processing

the default tokens that can be sent for stream processing

t()

the stream data structure

Functions

sends an iodata payload to the stdin of the ssh stream

sends an end-of-file to the the ssh stream.

Link to this section Types

Link to this type

control_message()

View Source
control_message() ::
  {:eof, SSH.chan()}
  | {:exit_status, SSH.chan(), integer()}
  | {:closed, SSH.chan()}

ssh protocol stream control messages

Link to this type

iostream_message()

View Source
iostream_message() :: {:data, SSH.chan(), 0 | 1, binary()}

binary data sent over the server's standard out (0) or standard error (1)

Link to this type

outbound_message()

View Source
outbound_message() :: {:send, SSH.chan(), binary()} | {:send_eof, SSH.chan()}

messages that the local client can use to send streaming content

Link to this type

process_fn()

View Source
process_fn() :: (binary(), acc :: term() -> {[term()], acc :: term()})

a lambda that acts on channel data and convert it to stream tokens

all messages that are blocked by the stream control loop.

Note that most of these are the third term in a {:ssh_cm, conn, <message>} tuple.

Link to this type

stream_control_tokens()

View Source
stream_control_tokens() :: :eof | {:retval, integer()} | :halt

the default tokens that can be sent for stream processing

Link to this type

stream_tokens()

View Source
stream_tokens() ::
  {:stdout, binary()}
  | {:stderr, binary()}
  | {:stream, binary()}
  | stream_control_tokens()

the default tokens that can be sent for stream processing

Link to this type

t()

View Source
t() :: %SSH.Stream{
  chan: SSH.chan(),
  conn: SSH.conn(),
  data: any(),
  data_timeout: timeout(),
  fds: [],
  halt: boolean(),
  on_stderr: process_fn(),
  on_stdout: process_fn(),
  on_timeout: (t() -> {list(), t()}),
  stop_time: DateTime.t(),
  stream_control_messages: boolean()
}

the stream data structure

Link to this section Functions

Link to this function

send_data(stream, payload)

View Source
send_data(t(), iodata()) :: :ok

sends an iodata payload to the stdin of the ssh stream

You should use this method inside of stderr, stdout, and data_timeout functions when you're designing interactive ssh handlers. Note that this function must be called from within the same process that the stream is running on, while the stream is running.

In the future, we might write a guard that will prevent you from doing this from another process.

Link to this function

send_eof(stream)

View Source
send_eof(t()) :: :ok

sends an end-of-file to the the ssh stream.

You should use this method inside of stderr, stdout, and data_timeout functions when you're designing interactive ssh handlers. Note that this function must be called from within the same process that the stream is running on, while the stream is running.

In the future, we might write a guard that will prevent you from doing this from another process.