{"id":20179004,"url":"https://github.com/charted-dev/snowflake","last_synced_at":"2025-05-07T01:35:26.193Z","repository":{"id":105819073,"uuid":"575066859","full_name":"charted-dev/snowflake","owner":"charted-dev","description":"Kotlin library to help generate Twitter snowflakes","archived":false,"fork":false,"pushed_at":"2023-10-06T05:34:19.000Z","size":445,"stargazers_count":4,"open_issues_count":11,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2023-10-06T12:43:16.163Z","etag":null,"topics":["kotlin","snowflake","twitter-snowflake"],"latest_commit_sha":null,"homepage":"https://charted-dev.github.io/snowflake","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/charted-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null}},"created_at":"2022-12-06T17:21:13.000Z","updated_at":"2023-10-05T17:40:42.000Z","dependencies_parsed_at":"2023-10-05T09:24:06.413Z","dependency_job_id":null,"html_url":"https://github.com/charted-dev/snowflake","commit_stats":null,"previous_names":[],"tags_count":1,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charted-dev%2Fsnowflake","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charted-dev%2Fsnowflake/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charted-dev%2Fsnowflake/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charted-dev%2Fsnowflake/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/charted-dev","download_url":"https://codeload.github.com/charted-dev/snowflake/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224553822,"owners_count":17330523,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kotlin","snowflake","twitter-snowflake"],"created_at":"2024-11-14T02:24:29.533Z","updated_at":"2024-11-14T02:24:30.074Z","avatar_url":"https://github.com/charted-dev.png","language":"Kotlin","readme":"# 🐻‍❄️❄️ Snowflake\n\u003e *Easy to use Kotlin library to help you generate Twitter snowflakes asynchronously*\n\u003e \n\u003e \u003ckbd\u003e[v0.1-beta](https://github.com/charted-dev/snowflake/releases/v0.1-beta)\u003c/kbd\u003e | [:scroll: **Documentation**](https://charted-dev.github.io/snowflake)\n\n**Snowflake** is a Kotlin multiplatform library to help you generate Twitter snowflakes in a single node environment or in a clustered environment.\nThis library was majorly inspired by [@bwmarrin](https://github.com/bwmarrin)'s [Go Snowflake](https://github.com/bwmarrin/snowflake) library.\n\n## Features\n- Distributed snowflake to help you generate snowflakes on each node with the `SnowflakeNodes` API.\n- **kotlinx.serialization** support to easily (de)serialize snowflakes.\n- Simple and usable way to generate Twitter snowflakes\n- **Asynchronous** support via Kotlin's coroutines\n\n## Usage\nView the [installation guide](#installation) on how to install the library in your Kotlin project.\n\nThe formatting of the snowflake is relatively the same as the [ID Format](https://github.com/bwmarrin/snowflake#id-format) that\nTwitter uses.\n\n```kotlin\n// Defaults with node 0 and epoch of Twitter's snowflake\nval snowflake = Snowflake()\n\nval id = snowflake.generate()\n// =\u003e returns [org.noelware.charted.snowflake.ID]\n```\n\n## Benchmaking\nSince generating snowflakes should be fast as possible, we provide a benchmark suite in the [benchmarks](./benchmarks) folder with [kotlinx.benchmark](https://github.com/Kotlin/kotlinx-benchmark)\n\n### Native\n```\n\u003e Task :benchmarks:nativeBenchmark\nRunning 'main' benchmarks for 'native'\nnative: org.noelware.charted.snowflake.benchmarks.native.SnowflakeNativeBenchmarks.generateIds\nWarm-up #0: 0.00240547 ms/op\nWarm-up #1: 0.00380899 ms/op\nWarm-up #2: 0.00514744 ms/op\nIteration #0: 0.00553965 ms/op\nIteration #1: 0.00633540 ms/op\nIteration #2: 0.00641139 ms/op\nIteration #3: 0.00698136 ms/op\nIteration #4: 0.00878726 ms/op\n  ~ 0.00681101 ms/op ±15%\n\nnative summary:\nBenchmark                              Mode  Cnt  Score   Error  Units\nSnowflakeNativeBenchmarks.generateIds  avgt    5  0.007 ± 0.001  ms/op\n```\n\n### JVM\n```\n\u003e Task :benchmarks:jvmBenchmark\nRunning 'main' benchmarks for 'jvm'\njvm: org.noelware.charted.snowflake.benchmarks.jvm.SnowflakeJvmBenchmarks.generateIds\n\nWarm-up 1: 0.001 ms/op\nWarm-up 2: ≈ 10⁻⁴ ms/op\nWarm-up 3: ≈ 10⁻⁴ ms/op\nWarm-up 4: ≈ 10⁻⁴ ms/op\nWarm-up 5: ≈ 10⁻⁴ ms/op\nIteration 1: ≈ 10⁻⁴ ms/op\nIteration 2: ≈ 10⁻⁴ ms/op\nIteration 3: ≈ 10⁻⁴ ms/op\nIteration 4: ≈ 10⁻⁴ ms/op\nIteration 5: ≈ 10⁻⁴ ms/op\n\nWarm-up 1: 0.001 ms/op\nWarm-up 2: ≈ 10⁻⁴ ms/op\nWarm-up 3: ≈ 10⁻⁴ ms/op\nWarm-up 4: ≈ 10⁻⁴ ms/op\nWarm-up 5: ≈ 10⁻⁴ ms/op\nIteration 1: ≈ 10⁻⁴ ms/op\nIteration 2: ≈ 10⁻⁴ ms/op\nIteration 3: ≈ 10⁻⁴ ms/op\nIteration 4: ≈ 10⁻⁴ ms/op\nIteration 5: ≈ 10⁻⁴ ms/op\n\nWarm-up 1: 0.001 ms/op\nWarm-up 2: ≈ 10⁻⁴ ms/op\nWarm-up 3: ≈ 10⁻⁴ ms/op\nWarm-up 4: ≈ 10⁻⁴ ms/op\nWarm-up 5: ≈ 10⁻⁴ ms/op\nIteration 1: ≈ 10⁻⁴ ms/op\nIteration 2: ≈ 10⁻⁴ ms/op\nIteration 3: ≈ 10⁻⁴ ms/op\nIteration 4: ≈ 10⁻⁴ ms/op\nIteration 5: ≈ 10⁻⁴ ms/op\n\n≈ 10⁻⁴ ms/op\n\njvm summary:\nBenchmark                           Mode  Cnt   Score    Error  Units\nSnowflakeJvmBenchmarks.generateIds  avgt   15  ≈ 10⁻⁴           ms/op\n```\n\n## Installation\nTo install the **Snowflake** library, you will need to enable Noelware's [Maven repository](https://maven.noelware.org).\n\n### Gradle (Kotlin DSL)\n```kotlin\nrepositories {\n    maven(\"https://maven.noelware.org\")\n    mavenCentral()\n}\n\ndependencies { \n    implementation(\"org.noelware.charted.snowflake:snowflake:0.1-beta\")\n}\n```\n\n### Gradle (Groovy DSL)\n```groovy\nrepositories {\n    maven \"https://maven.noelware.org\"\n    mavenCentral()\n}\n\ndependencies {\n    implementation \"org.noelware.charted.snowflake:snowflake:0.1-beta\"\n}\n```\n\n### Maven\n```xml\n\u003crepositories\u003e\n    \u003crepository\u003e\n        \u003curl\u003ehttps://maven.noelware.org\u003c/url\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n\u003cdependencies\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003eorg.noelware.charted.snowflake\u003c/groupId\u003e\n        \u003cartifactId\u003esnowflake-jvm\u003c/artifactId\u003e\n        \u003cversion\u003e0.1-beta\u003c/version\u003e\n        \u003ctype\u003epom\u003c/type\u003e\n    \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\n## License\n**snowflake** is released under the **MIT License** with love by Noelware. \u003c3\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharted-dev%2Fsnowflake","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcharted-dev%2Fsnowflake","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharted-dev%2Fsnowflake/lists"}