This repository has been archived on 2026-05-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Alix von Schirp @ BootMedia Media Production 070dae5aeb Dependency update, Docker buildfile, Readme, LICENSE
+ Added Docker build file
+ added Readme.md
+ added LICENSE (GPLv3)
* replaced dependency slf4j-api with logback
+ added dependency jetbrains-annotations
+ added dependency okhttp3
- removed build plugin central-publishing
+ added logback config files
2024-05-09 19:50:24 +02:00
2024-05-08 22:44:23 +02:00

SnowflakeService

A tool/microservice to centrally generate snowflake IDs. Can be run distributed.

GitHub License GitHub Issues or Pull Requests GitHub repo size GitHub Release

Acknowledgements

This utility uses:

Installation

  docker pull bootmediaalix/snowflake-service
  docker run bootmediaalix/snowflake-service -e %{set required .env, see below} -p 95674:95674 -v /data/b00tload-services/snowflake:%desired path on host%

Containerless

A containerless installation is possible, although not supported. For development convenience the application base directory is located in ~/.b00tload-services/snowflake instead of /data/b00tload-services/snowflake. If you want to work containerless you are on your own.

Environment Variables

To run this project, you will need to add the following environment variables to your .env file

EPOCH - the starting time of the snowflake

MACHINE_ID_BITS - the amount of bits used for the machine ID

SEQUENCE_BITS - the amount of bits used for the sequence counter

MACHINE_ID - the ID of the generator

or

ORCHESTRATOR_IP - an IP where a snowflake orchestrator is available to fetch all above values

or

EPOCH - the starting time of the snowflake

MACHINE_ID_BITS - the amount of bits used for the machine ID

SEQUENCE_BITS - the amount of bits used for the sequence counter

with neither MACHINE_ID nor ORCHESTRATOR_IP set, the Service will start as an orchestrator itself with MACHINE_ID = 0.

API Reference

Get an ID

  GET /flake

Response example:

{
    "snowflake": ""
}

Register worker (internal)

POST /orchestra/register
Header Description
name Required. A name to recognize the worker by (e.g. hostname+pid+random number)

Response example: Http Status: 200

{
  "machineBits": "",
  "workerid": "",
  "sequenceBits": "",
  "epoch": ""
}

Response on error:

Value name Value description
Http Status 426 - Upgrade required
Upgrade Header content required software version

Worker heartbeat (internal)

GET /orchestra/heartbeat
Parameter Description
name the ID used in registration
workerID the workerID assigned by the orchestrator

HTTP status code responses:

Status Description
200 Ok
409 Conflict, please reregister

Maintainer

License

GNU GPL v3

Support

For support, open a ticket or email me at alix (at) ja-lol-ey (dot) de.

Description
A tool/microservice to centrally generate snowflake IDs. Can be run in a distributed system.
Readme GPL-3.0 62 KiB
1.1.0 Latest
2024-06-23 00:29:24 +02:00
Languages
Java 96%
Dockerfile 4%