SnmpKit.SnmpMgr.RequestIdGenerator (snmpkit v0.6.3)

Atomic request ID generator using ETS for thread-safe counter operations.

Provides unique request IDs for SNMP operations without requiring GenServer synchronization, eliminating serialization bottlenecks.

Summary

Functions

Returns a specification to start this module under a supervisor.

Gets the current counter value without incrementing.

Generates the next unique request ID.

Resets the counter to 0.

Starts the RequestIdGenerator GenServer.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

current_value()

Gets the current counter value without incrementing.

Useful for debugging and monitoring.

next_id()

Generates the next unique request ID.

Uses atomic ETS operations for thread-safe counter increment. Wraps around at 1000000 to prevent overflow.

Examples

iex> SnmpKit.SnmpMgr.RequestIdGenerator.next_id()
1

iex> SnmpKit.SnmpMgr.RequestIdGenerator.next_id()
2

reset()

Resets the counter to 0.

Primarily used for testing.

start_link(opts \\ [])

Starts the RequestIdGenerator GenServer.

Creates the ETS table for atomic counter operations.