ServiceBusManager

Struct ServiceBusManager 

Source
pub struct ServiceBusManager { /* private fields */ }
Expand description

The main service bus manager that orchestrates all service bus operations.

ServiceBusManager is the central coordinator for all Azure Service Bus operations, providing a unified interface for queue management, message handling, bulk operations, and resource management. It uses a command pattern to process operations through specialized handlers.

§Architecture

The manager is built around specialized command handlers:

§Thread Safety

All internal state is protected by async mutexes, making the manager safe to use across multiple async tasks and threads.

§Examples

use quetty_server::service_bus_manager::{ServiceBusManager, ServiceBusCommand};

let manager = ServiceBusManager::new(/* configuration */);

// Switch to a queue
let response = manager.execute_command(
    ServiceBusCommand::SwitchQueue {
        queue_name: "my-queue".to_string(),
        queue_type: "Queue".to_string(),
    }
).await;

// Get messages
let response = manager.execute_command(
    ServiceBusCommand::PeekMessages {
        max_count: 10,
        from_sequence: None,
    }
).await;

Implementations§

Source§

impl ServiceBusManager

Source

pub fn new( service_bus_client: Arc<Mutex<ServiceBusClient<BasicRetryPolicy>>>, http_client: Client, azure_ad_config: AzureAdConfig, statistics_config: StatisticsConfig, batch_config: BatchConfig, connection_string: String, ) -> Self

Creates a new ServiceBusManager with the specified configuration.

Initializes all command handlers and shared state components needed for Service Bus operations. The manager takes ownership of the provided clients and configuration.

§Arguments
  • service_bus_client - Azure Service Bus client for operations
  • http_client - HTTP client for Azure Management API calls
  • azure_ad_config - Azure AD configuration for authentication
  • statistics_config - Configuration for queue statistics collection
  • batch_config - Configuration for bulk operations
  • connection_string - Service Bus connection string for reconnection
§Returns

A fully configured ServiceBusManager ready for operations

Source

pub async fn execute_command( &self, command: ServiceBusCommand, ) -> ServiceBusResponse

Executes a service bus command and returns the response.

This is the main entry point for all Service Bus operations. Commands are dispatched to specialized handlers based on their type. Errors are caught and converted to error responses.

§Arguments
  • command - The service bus command to execute
§Returns

A ServiceBusResponse containing either the operation result or an error

§Examples
use quetty_server::service_bus_manager::{ServiceBusManager, ServiceBusCommand};

let manager = ServiceBusManager::new(/* args */);

let response = manager.execute_command(
    ServiceBusCommand::GetQueueStatistics {
        queue_name: "my-queue".to_string(),
        queue_type: "Queue".to_string(),
    }
).await;
Source

pub async fn get_azure_ad_token( config: &AzureAdConfig, ) -> Result<String, Box<dyn Error>>

Source

pub async fn list_queues_azure_ad( config: &AzureAdConfig, ) -> Result<Vec<String>, Box<dyn Error>>

Source

pub async fn list_namespaces_azure_ad( config: &AzureAdConfig, ) -> Result<Vec<String>, Box<dyn Error>>

Source

pub async fn get_current_queue(&self) -> Option<QueueInfo>

Source

pub async fn is_connected(&self) -> bool

Source

pub async fn get_producer_count(&self) -> usize

Source

pub async fn get_last_error(&self) -> Option<String>

Source

pub async fn handle_reset_connection( &self, ) -> ServiceBusResult<ServiceBusResponse>

Reset the entire AMQP connection by creating a new ServiceBusClient

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> SendBound for T
where T: Send,