carotte/queue
Types
pub type DeclaredQueue {
DeclaredQueue(
name: String,
message_count: Int,
consumer_count: Int,
)
}
Constructors
-
DeclaredQueue( name: String, message_count: Int, consumer_count: Int, )
pub type Deliver {
Deliver(
consumer_tag: String,
delivery_tag: Int,
redelivered: Bool,
exchange: String,
routing_key: String,
)
}
Constructors
-
Deliver( consumer_tag: String, delivery_tag: Int, redelivered: Bool, exchange: String, routing_key: String, )
pub type Payload {
Payload(
payload: String,
properties: List(publisher.PublishOption),
)
}
Constructors
-
Payload( payload: String, properties: List(publisher.PublishOption), )
Functions
pub fn as_durable(queue: Queue) -> Queue
If set, the queue will survive a broker restart
pub fn as_exclusive(queue: Queue) -> Queue
If set, only one subscriber can consume from the Queue
pub fn as_passive(queue: Queue) -> Queue
If set, the queue must already exist on the broker
pub fn bind(
channel channel: Channel,
queue queue: String,
exchange exchange: String,
routing_key routing_key: String,
) -> Result(Nil, CarotteError)
Bind a queue to an exchange
The routing_key
is used to filter messages from the exchange
pub fn bind_async(
channel channel: Channel,
queue queue: String,
exchange exchange: String,
routing_key routing_key: String,
) -> Result(Nil, CarotteError)
Bind a queue to an exchange asynchronously. Same semantics as bind
pub fn declare(
queue: Queue,
channel: Channel,
) -> Result(DeclaredQueue, CarotteError)
Declare a queue on the broker
pub fn declare_async(
queue: Queue,
channel: Channel,
) -> Result(Nil, CarotteError)
Declare a queue on the broker asynchronously
pub fn delete(
channel channel: Channel,
queue queue: String,
if_unused if_unused: Bool,
if_empty if_empty: Bool,
) -> Result(Int, CarotteError)
Delete a queue from the broker
If if_unused
is set, the queue will only be deleted if it has no subscribers
If if_empty
is set, the queue will only be deleted if it has no messages
pub fn delete_async(
channel channel: Channel,
queue queue: String,
if_unused if_unused: Bool,
if_empty if_empty: Bool,
) -> Result(Nil, CarotteError)
Delete a queue from the broker asynchronously. Same semantics as delete
pub fn purge(
channel channel: Channel,
queue queue: String,
) -> Result(Int, CarotteError)
Purge a queue of all messages
pub fn purge_async(
channel channel: Channel,
queue queue: String,
) -> Result(Nil, CarotteError)
Purge a queue of all messages asynchronously
pub fn status(
channel channel: Channel,
queue queue: String,
) -> Result(DeclaredQueue, CarotteError)
Get the status of a queue
pub fn subscribe(
channel channel: Channel,
queue queue: String,
callback fun: fn(Payload, Deliver) -> Nil,
) -> Result(String, CarotteError)
Subscribe to a queue
The callback
function will be called with each message received, receiving the message Payload and a Deliver
struct
pub fn unbind(
channel channel: Channel,
queue queue: String,
exchange exchange: String,
routing_key routing_key: String,
) -> Result(Nil, CarotteError)
Unbind a queue from an exchange
The routing_key
is used to filter messages from the exchange
pub fn unsubscribe(
channel channel: Channel,
consumer_tag consumer_tag: String,
) -> Result(Nil, CarotteError)
Unsubscribe a consumer from a queue
pub fn unsubscribe_async(
channel channel: Channel,
consumer_tag consumer_tag: String,
) -> Result(Nil, CarotteError)
Unsubscribe a consumer from a queue asynchronously
pub fn with_auto_delete(queue: Queue) -> Queue
If set, the queue will be deleted when the last subscriber disconnect