Packages

p

lerna.util

sequence

package sequence

Lerna Util Sequence

Overview

The package provides an ID generator.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. sequence
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. abstract class CassandraSequenceFactory extends SequenceFactory with AppLogging

    A sequence factory using Cassandra

    A sequence factory using Cassandra

    Overview

    • Manage sequences using (seqId,subId) as a key
    • Reduce overhead by generating and persisting sequence beforehand
    • For each key (seqId,subId), hold the next IDs in memory

    seqID concept is introduced by this implementation. It can be thought of as a sub-namespace.

    Details

    Define an increment value as max server count (name it n) beforehand. Assign the different initial values (that is in the range [1 to n]) to each server. We can generate a unique ID using the above condition.

    For example, suppose we have 3 servers initially and scale it out to 5 servers in the future.

    Assign initial values as follows

    • Server A: (Assign an initial value = 1)
    • Server B: (Assign an initial value = 2)
    • Server C: (Assign an initial value = 3)

    Each server generates a sequence like the below

    • Server A generates a sequence 1, 6, 11, ..., Ai = 1 + n * i
    • Server B generates a sequence 2, 7, 12, ..., Bi = 2 + n * i
    • Server C generates a sequence 3, 8, 13, ..., Ci = 3 + n * i

    In the future, we can add two servers (named Server D and Server E).

    • Server D is assigned 4 as an initial value. It generates a sequence 4, 9, 14, ..., Di = 4 + n * i.
    • Server E is assigned 5 as an initial value. It generates a sequence 5, 10, 15, ..., Ei = 5 + n * i.

    Therefore, as we see the above, we can generate unique IDs.

    Annotations
    @SuppressWarnings()
  2. trait SequenceFactory extends AnyRef

    A trait that provides generating ID sequence

    A trait that provides generating ID sequence

    A concrete implementation for this trait must behave like below.

    • Generate unique ID only for the given subID This means that IDs generated with different subID can be the same value. We can think subID as a namespace.
    • A Generated ID should be in the range [0, maxSequence] (both inclusive)

    Behaviors that are not described above are dependent on a concrete implementation.

  3. class SequenceFactoryCassandraConfig extends AnyRef

Value Members

  1. object FutureConverters

Inherited from AnyRef

Inherited from Any

Ungrouped