GithubHelp home page GithubHelp logo

thibaultmeyer / libsnowflakeid Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 42 KB

Tiny, fast, and portable library to generate Snowflake IDs for C applications

License: MIT License

CMake 5.14% C 94.86%
snowflake-id library snowflakeid twitter snowflake-twitter idgenerator c thread-safe

libsnowflakeid's Introduction

libsnowflakeid

Latest release GitHub license CodeFactor Repository size

A tiny and portable library to generate Snowflake IDs.


Build & install from sources

To compile and install this project, you must ensure that make, cmake, gcc or clang or MSVC are being correctly installed.

#> mkdir cmake-build-release
#> cd cmake-build-release
#> cmake -DCMAKE_BUILD_TYPE=Release ..
#> make
#> make install

Usage

#include <snowflakeid.h>

int main(const int argc, const char *const *argv) {
    enum e_snowflakeid_init_status     status_out;
    struct s_snowflakeid_generator_ctx *ctx = snowflakeid_initialize(
            datacenter_id,
            worker_id,
            offset_time_ms,
            &status_out);
    
    if (status_out == SNOWFLAKEID_INIT_SUCCESS) {
        uint64_t id = snowflakeid_next_value(ctx);
        
        snowflakeid_destroy(ctx);
    }
    
    return (0);
}
#> cc example.c -lsnowflakeid

License

This project is released under terms of the MIT license.

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.