trevrpc/channel

A connection to a TrevRPC server, which reconnects on its own: native QUIC, QMux over TLS where UDP is blocked, or whichever connects first.

Types

A channel: the process that keeps the connection.

pub type Channel
pub type Config {
  Config(
    host: String,
    port: Int,
    tcp_port: option.Option(Int),
    transport: Transport,
    server_name: option.Option(String),
    ca_file: option.Option(String),
    verify: Bool,
    max_frame_size: option.Option(Int),
    connect_timeout: option.Option(Int),
    idle_timeout: option.Option(Int),
    min_quic_connections: option.Option(Int),
    max_quic_connections: option.Option(Int),
  )
}

Constructors

  • Config(
      host: String,
      port: Int,
      tcp_port: option.Option(Int),
      transport: Transport,
      server_name: option.Option(String),
      ca_file: option.Option(String),
      verify: Bool,
      max_frame_size: option.Option(Int),
      connect_timeout: option.Option(Int),
      idle_timeout: option.Option(Int),
      min_quic_connections: option.Option(Int),
      max_quic_connections: option.Option(Int),
    )

    Arguments

    tcp_port

    The server’s TCP listener, by default on the QUIC port number.

    server_name

    The name the server’s certificate must have, by default host.

    ca_file

    A PEM file of the certificates to trust, which may be the server’s own self-signed one; the system’s without.

    min_quic_connections

    How many QUIC connections the channel keeps open and spreads its calls over, by default one; QMux over TLS always uses one.

    max_quic_connections

    How many QUIC connections the channel’s pool grows to under load, by default the schedulers online, from one to four.

pub type Transport {
  Auto
  Quic
  Tcp
}

Constructors

  • Auto

    QUIC, racing QMux over TLS once QUIC has not connected after a delay.

  • Quic
  • Tcp

    QMux over TLS.

Values

pub fn close(channel: Channel) -> Nil

Closes the channel, ending its calls.

pub fn config(host: String, port: Int) -> Config

A channel to host and port, with every other option at its default.

pub fn connect(
  config: Config,
  timeout: Int,
) -> Result(Channel, status.Status)

Starts a channel, linked to the calling process, and waits up to timeout milliseconds for it to connect. The channel closes when that process exits.

✨ Search Document