GithubHelp home page GithubHelp logo

avielyo10 / goflake Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 120 KB

Goflake is a disributed uuid generator.

License: GNU General Public License v3.0

Makefile 1.92% Go 93.69% Dockerfile 4.40%
distributed snowflake uuid-generator

goflake's Introduction

GoFlake

Goflake is a disributed uuid generator. By default it uses SnowFlake configuration.

Goflake comes with both grpc and http servers so you can use it in your own applications without any additional dependencies (including TLS).

See announcing snowflake by Twitter.

Install

go install github.com/Avielyo10/goflake@latest

Configuration

Goflake will try to read configuration from /etc/goflake/config.yaml or $CWD/config.yaml if it exists, else default will apply. You can also specify configuration from environment variables to override configuration from file.

For example:

env "SERVER.TYPE=rest" DATACENTER_ID=1 MACHINE_ID=2 go run .

Configuration File in detail

  • log_level: either debug, info, warn, error, fatal

  • env: either development, production

  • datacenter_id: can be 0 - 2 ^ flake.bits_len.datacenter_id - 1

  • machine_id: can be 0 - 2 ^ flake.bits_len.machine_id - 1

  • flake configuration

    • bits_len: bits length of flake id, needs to sum to 63 (1 bit for sign)
      • datacenter_id: uint64, default 5
      • machine_id: uint64, default 5
      • sequence: uint64, default 12
      • time: uint64, default 41
    • epoch: epoch of flake id, default is Thu Jul 28 2022 18:57:35 UTC
    • tick_ms: tick interval in milliseconds to set sequence to 0, default is 1ms
  • server configuration

    • host: server host
    • port: server port
    • tls configuration
      • cert_path: path to certificate file
      • key_path: path to key file
    • type: either grpc, rest

See example config

goflake's People

Contributors

avielyo10 avatar dependabot[bot] avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.