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:
QueueCommandHandler- Queue switching and statisticsMessageCommandHandler- Message retrieval and completionSendCommandHandler- Message sending operationsStatusCommandHandler- Connection and status monitoringBulkCommandHandler- Bulk message operationsResourceCommandHandler- Resource discovery and management
§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
impl ServiceBusManager
Sourcepub 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
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 operationshttp_client- HTTP client for Azure Management API callsazure_ad_config- Azure AD configuration for authenticationstatistics_config- Configuration for queue statistics collectionbatch_config- Configuration for bulk operationsconnection_string- Service Bus connection string for reconnection
§Returns
A fully configured ServiceBusManager ready for operations
Sourcepub async fn execute_command(
&self,
command: ServiceBusCommand,
) -> ServiceBusResponse
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;pub async fn get_azure_ad_token( config: &AzureAdConfig, ) -> Result<String, Box<dyn Error>>
pub async fn list_queues_azure_ad( config: &AzureAdConfig, ) -> Result<Vec<String>, Box<dyn Error>>
pub async fn list_namespaces_azure_ad( config: &AzureAdConfig, ) -> Result<Vec<String>, Box<dyn Error>>
pub async fn get_current_queue(&self) -> Option<QueueInfo>
pub async fn is_connected(&self) -> bool
pub async fn get_producer_count(&self) -> usize
pub async fn get_last_error(&self) -> Option<String>
Sourcepub async fn handle_reset_connection(
&self,
) -> ServiceBusResult<ServiceBusResponse>
pub async fn handle_reset_connection( &self, ) -> ServiceBusResult<ServiceBusResponse>
Reset the entire AMQP connection by creating a new ServiceBusClient