A tiny and portable library to generate Snowflake IDs.
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
#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
This project is released under terms of the MIT license.