Search documentation of snmpkit

# SnmpKit.SnmpMgr.RequestIdGenerator (snmpkit v1.3.17)

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

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

current_value()

Gets the current counter value without incrementing.

next_id()

Generates the next unique request ID.

reset()

Resets the counter to 0.

start_link(opts \\ [])

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.