SnmpKit.SnmpMgr.Router (snmpkit v0.6.6)
Intelligent request routing and load balancing for SNMP requests.
This module provides sophisticated routing strategies to optimize request distribution across multiple engines and target devices, with support for load balancing, affinity routing, and performance-based routing decisions.
Summary
Functions
Adds an engine to the routing pool.
Attempts to recover a failed engine.
Returns a specification to start this module under a supervisor.
Configures batch processing strategy.
Configures engine settings.
Configures health check settings.
Gets engine health information.
Gets routing statistics and engine health.
Marks an engine as healthy.
Marks an engine as unhealthy.
Removes an engine from the routing pool.
Routes multiple requests as a batch.
Routes a request to the best available engine.
Sets engine weights for weighted routing.
Updates routing strategy.
Starts the request router.
Functions
Adds an engine to the routing pool.
Attempts to recover a failed engine.
Returns a specification to start this module under a supervisor.
See Supervisor
.
Configures batch processing strategy.
Configures engine settings.
Configures health check settings.
Gets engine health information.
Gets routing statistics and engine health.
Marks an engine as healthy.
Marks an engine as unhealthy.
Removes an engine from the routing pool.
Routes multiple requests as a batch.
Parameters
router
- Router PID or namerequests
- List of request specificationsopts
- Routing options
Examples
requests = [
%{type: :get, target: "device1", oid: "sysDescr.0"},
%{type: :get, target: "device2", oid: "sysUpTime.0"}
]
{:ok, results} = SnmpKit.SnmpMgr.Router.route_batch(router, requests)
Routes a request to the best available engine.
Parameters
router
- Router PID or namerequest
- Request specificationopts
- Routing options
Examples
request = %{
type: :get,
target: "192.168.1.1",
oid: "sysDescr.0"
}
{:ok, result} = SnmpKit.SnmpMgr.Router.route_request(router, request)
Sets engine weights for weighted routing.
Updates routing strategy.
Starts the request router.
Options
:strategy
- Routing strategy (:round_robin, :least_connections, :weighted, :affinity):engines
- List of engine specifications:health_check_interval
- Health check interval in ms (default: 30000):max_retries
- Maximum retry attempts (default: 3)
Examples
{:ok, router} = SnmpKit.SnmpMgr.Router.start_link(
strategy: :least_connections,
engines: [
%{name: :engine1, weight: 2, max_load: 100},
%{name: :engine2, weight: 1, max_load: 50}
]
)