| Crates.io | lmrc-rabbitmq |
| lib.rs | lmrc-rabbitmq |
| version | 0.3.16 |
| created_at | 2025-11-30 23:19:07.070569+00 |
| updated_at | 2025-12-11 13:29:08.883924+00 |
| description | RabbitMQ management library for the LMRC Stack - comprehensive library for managing RabbitMQ installations on remote servers via SSH |
| homepage | https://gitlab.com/lemarco/lmrc-stack/tree/main/libs/rabbitmq-manager |
| repository | https://gitlab.com/lemarco/lmrc-stack |
| max_upload_size | |
| id | 1958996 |
| size | 56,802 |
RabbitMQ management library for the LMRC Stack - comprehensive library for managing RabbitMQ installations on remote servers via SSH.
Add this to your Cargo.toml:
[dependencies]
lmrc-rabbitmq = "0.3.9"
use lmrc_rabbitmq::{RabbitMqManager, RabbitMqConfig};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create configuration
let config = RabbitMqConfig::builder()
.version("latest")
.admin_user("admin")
.admin_password("secure_password")
.enable_management(true)
.management_port(15672)
.amqp_port(5672)
.configure_firewall(true)
.build();
// Create manager
let manager = RabbitMqManager::new("192.168.1.10")
.with_port(22)
.with_user("root");
// Install RabbitMQ
manager.install(&config)?;
// Get connection string
let connection_string = manager.connection_string(
"admin",
"secure_password",
"/",
5672
);
println!("Connection string: {}", connection_string);
Ok(())
}
The manager handles the complete installation process:
let config = RabbitMqConfig::builder()
.version("3.12.0")
.admin_user("admin")
.admin_password("my_password")
.enable_management(true)
.build();
let manager = RabbitMqManager::new("server.example.com")
.with_user("root");
manager.install(&config)?;
This will:
use lmrc_rabbitmq::{RabbitMqUser, RabbitMqManager};
let mut ssh_client = /* ... */;
let mut user_ops = lmrc_rabbitmq::operations::UserOperations::new(&mut ssh_client);
// Create user
let user = RabbitMqUser {
username: "myuser".to_string(),
password: "mypassword".to_string(),
tags: vec!["administrator".to_string()],
};
user_ops.create_user(&user)?;
// List users
let users = user_ops.list_users()?;
use lmrc_rabbitmq::{RabbitMqVHost, operations::VHostOperations};
let mut vhost_ops = VHostOperations::new(&mut ssh_client);
// Create vhost
let vhost = RabbitMqVHost {
name: "my-vhost".to_string(),
};
vhost_ops.create_vhost(&vhost)?;
use lmrc_rabbitmq::{RabbitMqPermission, operations::PermissionOperations};
let mut perm_ops = PermissionOperations::new(&mut ssh_client);
// Set permissions
let permission = RabbitMqPermission {
user: "myuser".to_string(),
vhost: "/".to_string(),
configure: ".*".to_string(),
write: ".*".to_string(),
read: ".*".to_string(),
};
perm_ops.set_permissions(&permission)?;
This library follows hexagonal architecture principles:
lmrc-ports cratelmrc-sshAll operations return Result<T, RabbitMqError> with detailed error types:
use lmrc_rabbitmq::RabbitMqError;
match manager.install(&config) {
Ok(_) => println!("Installation successful"),
Err(RabbitMqError::Ssh(e)) => eprintln!("SSH error: {}", e),
Err(RabbitMqError::InstallationFailed(msg)) => eprintln!("Installation failed: {}", msg),
Err(e) => eprintln!("Error: {}", e),
}
Dual licensed under MIT OR Apache-2.0 (user's choice).
This library is part of the LMRC Stack project.