View Source ExRocketmq.Util.UniqId (lib_oss v0.1.0)
Utility module for generating unique IDs for RocketMQ messages or requests.
A unique ID consists of two parts:
- Prefix: IP address and process ID
- Gap timestamp + counter
The prefix is composed of the IP address and process ID of the current process. The gap timestamp is the difference between the current time and the start of the current month, in milliseconds. The counter is an auto-incrementing number for each process.
This module uses an Agent to keep track of the state of the counter and timestamp.
Examples
iex> ExRocketmq.Util.UniqId.get_uniq_id(pid)
"0A93667D3B0A0000000063952A000001"
Summary
Functions
Returns a specification to start this module under a supervisor.
generate a unique id
start a uniqid generater agent
Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
generate a unique id
Examples
iex> ExRocketmq.Util.UniqId.get_uniq_id(pid)
"0A93667D3B0A0000000063952A000001"
@spec start_link(Keyword.t()) :: Agent.on_start()
start a uniqid generater agent