Class l2df.manager.gsid

Last updated 2021-05-28 15:24:22

Global Synchronized Identifier generator.

Its main advantages are simplicity and ability to revert its inner state.

Info:

Functions

Manager:init([kwargs]) Configure GSID manager.
Manager:advance(dt) Advances inner counter used for generation of GSIDs.
Manager:generate() Generates next GSID hash value from the inner state.
Manager:hash(state, salt) Generates new GSID hash value using specified state and salt.
Manager:rand() Generates random GSID.


Functions

Methods
Manager:init([kwargs])
Configure GSID manager.

Parameters:

  • kwargs table
    • seed number Generator needs a number to start with (a seed value), to be able to generate GSID's sequences. (default 1)
    • step number Generator's fixed step value for updating the inner state by calling GSID:advance() method. (default 1)
    • salt number Additional salt used in hash generation. Can be used to generate different GSID's sequences for the same initial seed. (default 1)

Returns:

    l2df.manager.gsid
Manager:advance(dt)
Advances inner counter used for generation of GSIDs. Note that it doesn't affect generator's state immediately because it updates with the fixed step. So the specified delta will be accumulated and applied to the state as soon as it achieves the step value.

Parameters:

  • dt number Delta value to advance the inner generator's counter. Could be a positive or negative number.
Manager:generate()
Generates next GSID hash value from the inner state.

Returns:

    string HEX representation of the generated GSID.
Manager:hash(state, salt)
Generates new GSID hash value using specified state and salt.

Parameters:

  • state number Source state value. Must be greater than zero.
  • salt number Additional salt value. Must be greater than zero.

Returns:

    string HEX representation of the generated GSID.
Manager:rand()
Generates random GSID.

Returns:

    number Number representation of the generated GSID.