hare v0.2.2 Hare.Core.Chan

This module defines the Hare.Core.Chan struct that represents an open channel and provides functions to interact with it.

Summary

Functions

Closes the given channel

Establishes a link with the given channel process

Monitors the given channel process

It buids a new Hare.Core.Chan struct from an adapter’s channel representation and the adapter itself

It opens a new connection on the given connection process

Configures the Quality Of Service

Register a handler to deal with returned messages

Unlinks the given channel process fron the caller. If they are not linked it does nothing

Remove the return handler, if it exists. Does nothing if there is no such handler

Types

t()
t() :: %Hare.Core.Chan{adapter: Hare.Adapter.t, given: Hare.Adapter.chan}

Functions

close(chan)
close(t) :: :ok

Closes the given channel.

The channel should not be used after calling this function.

link(chan)
link(t) :: true

Establishes a link with the given channel process.

monitor(chan)
monitor(t) :: reference

Monitors the given channel process.

new(given, adapter)

It buids a new Hare.Core.Chan struct from an adapter’s channel representation and the adapter itself.

This function is not meant to be called directly, but from a Hare.Core.Conn module.

Use open/1 to open new channels.

open(conn, timeout \\ 5000)
open(conn :: GenServer.server, timeout) ::
  {:ok, t} |
  {:error, reason :: term}

It opens a new connection on the given connection process.

The connection process is expected to be a instance of the Hare.Core.Conn module.

If the connection is not established, it blocks until it is established. A timeout in ms may be specified for this operation (5 seconds by default).

qos(chan, opts \\ [])
qos(t, Hare.Adapter.opts) :: :ok

Configures the Quality Of Service.

It delegates the given options to the underlying adapter. The format of these options depends on the adapter.

register_return_handler(chan, pid \\ self())

Register a handler to deal with returned messages.

unlink(chan)
unlink(t) :: true

Unlinks the given channel process fron the caller. If they are not linked it does nothing.

unregister_return_handler(chan)
unregister_return_handler(t) :: :ok

Remove the return handler, if it exists. Does nothing if there is no such handler.