carotte

Types

Configuration builder for creating a RabbitMQ client. Use default_client() to create a builder with sensible defaults, then chain the with_* functions to customize the configuration.

pub opaque type Builder

Errors that can occur when interacting with RabbitMQ.

pub type CarotteError {
  Blocked
  Closed
  AuthFailure(String)
  ProcessNotFound
  AlreadyRegistered(String)
  NotFound(String)
  AccessRefused(String)
  PreconditionFailed(String)
  ResourceLocked(String)
  ChannelClosed(String)
  ConnectionRefused(String)
  ConnectionTimeout(String)
  FrameError(String)
  InternalError(String)
  InvalidPath(String)
  NoRoute(String)
  NotAllowed(String)
  NotImplemented(String)
  UnexpectedFrame(String)
  CommandInvalid(String)
  UnknownError(String)
}

Constructors

  • Blocked

    The connection is blocked by the server due to resource constraints

  • Closed

    The connection or channel has been closed

  • AuthFailure(String)

    Authentication failed with the provided credentials

  • ProcessNotFound

    The specified process could not be found

  • AlreadyRegistered(String)

    The resource is already registered with the given name

  • NotFound(String)

    The requested resource was not found

  • AccessRefused(String)

    Access to the resource was refused

  • PreconditionFailed(String)

    A precondition for the operation failed

  • ResourceLocked(String)

    The resource is locked and cannot be accessed

  • ChannelClosed(String)

    The channel has been closed

  • ConnectionRefused(String)

    Connection to the server was refused

  • ConnectionTimeout(String)

    Connection attempt timed out

  • FrameError(String)

    An error occurred while processing AMQP frames

  • InternalError(String)

    An internal server error occurred

  • InvalidPath(String)

    The provided path is invalid

  • NoRoute(String)

    No route exists to the specified exchange or queue

  • NotAllowed(String)

    The requested operation is not allowed

  • NotImplemented(String)

    The requested feature is not implemented

  • UnexpectedFrame(String)

    An unexpected frame was received

  • CommandInvalid(String)

    The AMQP command is invalid

  • UnknownError(String)

    An unknown error occurred

Represents an active connection to a RabbitMQ server. This is an opaque type that encapsulates the underlying AMQP client process. Use the builder pattern with default_client() and start() to create a client.

pub opaque type Client

Values

pub fn close(client: Client) -> Result(Nil, CarotteError)

Close the RabbitMQ client connection. This will close all channels and the underlying AMQP connection.

pub fn default_client() -> Builder

Create a new client builder with default settings. Uses guest/guest credentials on localhost:5672.

Example

let client = carotte.default_client(process.new_name("my_client"))
  |> carotte.start()
pub fn start(builder: Builder) -> Result(Client, CarotteError)

Start a RabbitMQ client connection. Returns an actor.StartResult which contains the client on success.

Example

case carotte.start(builder) {
  Ok(client) -> // Use the client
  Error(carotte_error) -> // Handle connection error
}
pub fn with_channel_max(
  builder: Builder,
  channel_max: Int,
) -> Builder

Set the maximum number of channels (default: 2074)

pub fn with_connection_timeout(
  builder: Builder,
  connection_timeout: Int,
) -> Builder

Set the connection timeout in milliseconds (default: 60000)

pub fn with_frame_max(
  builder: Builder,
  frame_max: Int,
) -> Builder

Set the maximum frame size in bytes (0 = no limit)

pub fn with_heartbeat(
  builder: Builder,
  heartbeat: Int,
) -> Builder

Set the heartbeat interval in seconds (default: 10)

pub fn with_host(builder: Builder, host: String) -> Builder

Set the hostname or IP address of the RabbitMQ server

pub fn with_password(
  builder: Builder,
  password: String,
) -> Builder

Set the password for authentication

pub fn with_port(builder: Builder, port: Int) -> Builder

Set the port number for the RabbitMQ server (default: 5672)

pub fn with_username(
  builder: Builder,
  username: String,
) -> Builder

Set the username for authentication

pub fn with_virtual_host(
  builder: Builder,
  virtual_host: String,
) -> Builder

Set the virtual host to connect to

Search Document