gluegun/connection
gluegun/connection
Section titled “gluegun/connection”Connection management for Erlang Gun.
Open a Gun process, wait for it to be ready, choose transport and HTTP protocol preferences, then close or shut down the connection. Connections are Erlang process resources and are available on the Erlang target only.
ConnectOptions
Section titled “ConnectOptions”Pure representation of connection options before FFI conversion.
Protocol
Section titled “Protocol”HTTP protocol preference for a Gun connection.
Http2 is encoded as Gun's http2 protocol atom, so it can be placed
before Http1 when TLS + ALPN should prefer HTTP/2 and fall back to
HTTP/1.1.
Http1()Http2()
Timeout
Section titled “Timeout”Timeout or retry duration in milliseconds, or no limit.
Milliseconds(Int)Infinity()
Transport
Section titled “Transport”Transport selection for a Gun connection.
Auto()Tcp()Tls()
Functions
Section titled “Functions”await_up
Section titled “await_up”Wait until a Gun connection is up.
pub fn await_up(gluegun/internal.Connection, gluegun/connection.Timeout) -> Result(gluegun/connection.Protocol, gluegun/error.GluegunError)Close a Gun connection.
pub fn close(gluegun/internal.Connection) -> Result(Nil, gluegun/error.GluegunError)connect_timeout
Section titled “connect_timeout”Inspect connect timeout duration.
pub fn connect_timeout(gluegun/connection.ConnectOptions) -> gluegun/connection.TimeoutOpen a Gun connection.
pub fn open(gluegun/connection.ConnectOptions, host: String, port: Int) -> Result(gluegun/internal.Connection, gluegun/error.GluegunError)options
Section titled “options”Construct default connection options.
pub fn options() -> gluegun/connection.ConnectOptionsoptions_to_ffi
Section titled “options_to_ffi”Convert connection options to the Erlang FFI map shape.
pub fn options_to_ffi(gluegun/connection.ConnectOptions) -> gleam/dynamic.Dynamicprotocols
Section titled “protocols”Inspect explicitly configured protocol ordering, if any.
pub fn protocols(gluegun/connection.ConnectOptions) -> gleam/option.Option(List(gluegun/connection.Protocol))Inspect retry duration.
pub fn retry(gluegun/connection.ConnectOptions) -> gluegun/connection.Timeoutshutdown
Section titled “shutdown”Shut down a Gun connection.
pub fn shutdown(gluegun/internal.Connection) -> Result(Nil, gluegun/error.GluegunError)timeout_to_ffi
Section titled “timeout_to_ffi”Convert a timeout to the Erlang FFI shape.
pub fn timeout_to_ffi(gluegun/connection.Timeout) -> gleam/dynamic.Dynamictransport
Section titled “transport”Inspect configured transport. Intended for tests and later FFI conversion.
pub fn transport(gluegun/connection.ConnectOptions) -> gluegun/connection.Transportwith_connect_timeout
Section titled “with_connect_timeout”Set Gun's connect timeout option.
pub fn with_connect_timeout(gluegun/connection.ConnectOptions, timeout: gluegun/connection.Timeout) -> gluegun/connection.ConnectOptionswith_protocols
Section titled “with_protocols”Set HTTP protocol preference ordering for a connection.
The list order is preserved when options are passed to Gun.
pub fn with_protocols(gluegun/connection.ConnectOptions, protocols: List(gluegun/connection.Protocol)) -> gluegun/connection.ConnectOptionswith_retry
Section titled “with_retry”Set Gun's retry timeout option.
pub fn with_retry(gluegun/connection.ConnectOptions, retry: gluegun/connection.Timeout) -> gluegun/connection.ConnectOptionswith_transport
Section titled “with_transport”Set the transport Gun should use for a connection.
pub fn with_transport(gluegun/connection.ConnectOptions, transport: gluegun/connection.Transport) -> gluegun/connection.ConnectOptions