Package detail

eventid

google7.5mApache-2.02.0.1

A utility for generating monotonically increasing unique event ids across a network of services.

uid

readme

eventid

Monotonically increasing per machine, globally unique eventids

npm version Build Status Dependencies Known Vulnerabilities

Note: This is not an official Google product.

An eventId uniquely identifies an event across a network of services. It is globally unique, and is monotically increasing locally. This makes eventids useful for lexically comparable identifiers for events in a distributed system.

This can be used instead of timestamps – JavaScript timestamps only have millisecond resolution making them unsuitable for the purpose of building monotonically increasing local ids.

Installation

$ npm install eventid

Usage

const EventId = require('eventid');

// Instantiate a generator.
const eventId = new EventId();

// Generate a globally unique identifier.
const id1 = eventId.new(); // -> "..........37qqNkj4K24ulWyeuWxpZh"
// Use the same generator to get monotonically increasing local ids.
const id2 = eventId.new(); // -> "..........77qqNkj4K24ulWyeuWxpZh"
// You can lexicographically compare the ids.
assert(id1 < id2); // -> true

// Another instance will use a different guid
const another = new EventId();
const id3 = another.new(); // -> "..........5rkLYOc5W8ZAHAmVSyrixJ"

License

Apache 2.0

changelog

Changelog

2.0.1 (2021-12-06)

Bug Fixes

2.0.0 (2021-08-31)

⚠ BREAKING CHANGES

  • require node.js 10 and up (#88)

Bug Fixes

  • deps: update dependency uuid to v7 (#79) (1e8c47f)
  • deps: update dependency uuid to v8 (#92) (0a5ecea)

Build System

1.0.0 (2019-11-05)

⚠ BREAKING CHANGES

  • Stop supporting Node 6 as it reaches EOL.
  • drop support for node.js 4.x and 9.x (#25)

Features

Build System

Miscellaneous Chores

  • drop support for node.js 4.x and 9.x (#25) (f69a1b0)