struct Crabbit::Configuration

Overview

Immutable connection, authentication, timeout, and protocol configuration.

Configuration.parse is convenient for one URI endpoint. Construct this type directly to supply multiple entrypoints, custom SASL, or load-balancer mode.

Defined in:

crabbit/configuration.cr

Constant Summary

DEFAULT_URI = "rabbitmq-stream://guest:guest@localhost:5552/%2f"

Default local RabbitMQ Stream URI.

Constructors

Instance Method Summary

Constructor Detail

def self.new(endpoints : Array(Endpoint) = [Endpoint.new("localhost")], username : String = "guest", password : String = "guest", virtual_host : String = "/", sasl : SaslMechanism = SaslMechanism::Plain, sasl_authenticator : SaslAuthenticator | Nil = nil, oauth2 : OAuth2Config | Nil = nil, tls : TLSConfig | Nil = nil, heartbeat : Time::Span = 60.seconds, max_frame_size : UInt32 = 1048576_u32, connection_timeout : Time::Span = 10.seconds, request_timeout : Time::Span = 10.seconds, client_properties : Hash(String, String) = {} of String => String, load_balancer : Bool = false) #

Creates a connection configuration.

Crabbit rotates through endpoints for locator connections. With load_balancer, it also opens producer and consumer connections through those entrypoints until RabbitMQ advertises the metadata-selected node.

client_properties augment the default product, version, platform, and information fields. Supplying oauth2 creates a shared OAuth2SaslAuthenticator; oauth2 and sasl_authenticator are mutually exclusive.


[View source]
def self.parse(uri : String = DEFAULT_URI, tls : TLSConfig | Nil = nil, **options) : self #

Parses a RabbitMQ Stream URI into a configuration.

Supported schemes are rabbitmq-stream and rabbitmq-stream+tls. Username, password, and virtual host are percent-decoded. Additional named options are forwarded to .new.

tls = Crabbit::TLSConfig.new(custom_context)
config = Crabbit::Configuration.parse(
  "rabbitmq-stream+tls://user:secret@rabbit.example/%2f",
  tls: tls,
  heartbeat: 30.seconds,
)

[View source]

Instance Method Detail

def authenticator : SaslAuthenticator #

Returns the effective authenticator for this configuration.


[View source]
def client_properties : Hash(String, String) #

Returns client properties sent during Peer Properties negotiation.


[View source]
def connection_timeout : Time::Span #

Returns the TCP/TLS connection timeout.


[View source]
def endpoints : Array(Endpoint) #

Returns seed endpoints used for metadata and load-balanced connections.


[View source]
def heartbeat : Time::Span #

Returns the requested heartbeat interval; zero disables heartbeats.


[View source]
def load_balancer : Bool #

Returns whether broker connections must be reached through seed endpoints.


[View source]
def max_frame_size : UInt32 #

Returns the requested maximum frame size; zero means no local limit.


[View source]
def oauth2 : OAuth2Config | Nil #

Returns the optional OAuth 2 configuration.


[View source]
def password : String #

Returns the SASL PLAIN password.


[View source]
def request_timeout : Time::Span #

Returns the timeout for correlated protocol requests.


[View source]
def sasl : SaslMechanism #

Returns the selected built-in SASL mechanism.


[View source]
def sasl_authenticator : SaslAuthenticator | Nil #

Returns the optional custom SASL authenticator.


[View source]
def tls : TLSConfig | Nil #

Returns TLS settings, or nil for plain Stream connections.


[View source]
def username : String #

Returns the SASL PLAIN username.


[View source]
def virtual_host : String #

Returns the RabbitMQ virtual host.


[View source]