spoke/tcp

Types

Send, receive, and shutdown functions, as defined in the main spoke package.

pub type TransportChannel =
  #(
    fn(BytesTree) -> Result(Nil, String),
    fn() -> Selector(Result(BitArray, String)),
    fn() -> Nil,
  )

Re-definition of what spoke uses for transport channels (simplifies package dependencies).

pub type TransportChannelConnector =
  fn() -> Result(TransportChannel, String)

Functions

pub fn connector(
  host host: String,
  port port: Int,
  connect_timeout connect_timeout: Int,
) -> fn() ->
  Result(
    #(
      fn(BytesTree) -> Result(Nil, String),
      fn() -> Selector(Result(BitArray, String)),
      fn() -> Nil,
    ),
    String,
  )

Constructs an (unencrypted) TCP connector.

pub fn connector_with_defaults(
  host host: String,
) -> fn() ->
  Result(
    #(
      fn(BytesTree) -> Result(Nil, String),
      fn() -> Selector(Result(BitArray, String)),
      fn() -> Nil,
    ),
    String,
  )

Constructs an (unencrypted) TCP connector using the defaults of connecting to port 1883 on the given host.

Search Document