Skip to main content

Module pool

Module pool 

Source
Expand description

Async connection pool for managing NETCONF sessions to multiple devices.

DevicePool
  ├── Semaphore(max_connections) — global concurrency limit
  ├── devices: HashMap<name, DeviceConfig>
  └── connections: HashMap<name, Vec<Client>> — idle pool per device

  checkout("spine-01") → PoolGuard(Client) — auto-checkin on drop

§Example

use rustnetconf::pool::{DevicePool, DeviceConfig};
use rustnetconf::transport::ssh::SshAuth;
use rustnetconf::Datastore;

let pool = DevicePool::builder()
    .max_connections(50)
    .add_device("spine-01", DeviceConfig {
        host: "10.0.0.1:830".into(),
        username: "admin".into(),
        auth: SshAuth::Password("secret".into()),
        vendor: None,
    })
    .build();

let mut conn = pool.checkout("spine-01").await?;
let config = conn.get_config(Datastore::Running).await?;
// conn auto-returned to pool when dropped

Structs§

DeviceConfig
Configuration for a single device in the pool.
DevicePool
Async connection pool for multi-device NETCONF operations.
DevicePoolBuilder
Builder for constructing a DevicePool.
PoolGuard
A checked-out connection from the pool.