Packages
amqp
1.3.2
4.1.1
4.1.0
4.0.0
4.0.0-rc.1
3.3.2
3.3.1
retired
3.3.0
3.2.0
3.1.1
3.1.0
3.0.1
3.0.0
3.0.0-rc.1
2.1.2
2.1.1
2.1.0
2.0.0
2.0.0-rc.2
2.0.0-rc.1
1.6.0
1.5.0
1.4.2
1.4.1
1.4.0
1.4.0-rc.0
1.3.2
1.3.1
1.3.0
1.2.2
1.2.1
1.2.0
1.2.0-rc.0
1.1.1
1.1.0
1.0.3
1.0.2
1.0.1
1.0.0
1.0.0-pre.4
1.0.0-pre.3
1.0.0-pre.2
1.0.0-pre.1
0.3.1
0.3.0
0.2.4
0.2.3
0.2.2
0.2.1
0.2.0
0.2.0-pre.2
0.2.0-pre.1
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0
0.0.6
0.0.5
0.0.4
0.0.3
Idiomatic Elixir client for RabbitMQ.
Current section
Files
Jump to
Current section
Files
lib/amqp/channel.ex
defmodule AMQP.Channel do
@moduledoc """
Functions to operate on Channels.
"""
alias AMQP.{Connection, Channel}
defstruct [:conn, :pid]
@type t :: %Channel{conn: Connection.t, pid: pid}
@doc """
Opens a new Channel in a previously opened Connection.
"""
@spec open(Connection.t) :: {:ok, Channel.t} | {:error, any}
def open(%Connection{pid: pid} = conn) do
case :amqp_connection.open_channel(pid) do
{:ok, chan_pid} -> {:ok, %Channel{conn: conn, pid: chan_pid}}
error -> error
end
end
@doc """
Closes an open Channel.
"""
@spec close(Channel.t) :: :ok | {:error, AMQP.Basic.error}
def close(%Channel{pid: pid}) do
case :amqp_channel.close(pid) do
:ok -> :ok
error -> {:error, error}
end
end
end