{"id":23658881,"url":"https://github.com/mustafaturan/monoton","last_synced_at":"2025-09-01T12:31:39.737Z","repository":{"id":45486385,"uuid":"179940797","full_name":"mustafaturan/monoton","owner":"mustafaturan","description":"Highly scalable, single/multi node, sortable, predictable and incremental unique id generator with zero allocation magic on the sequential generation","archived":false,"fork":false,"pushed_at":"2024-03-24T22:14:08.000Z","size":74,"stargazers_count":34,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-02T16:53:56.151Z","etag":null,"topics":["go","golang","golang-library","golang-package","id-generator","ksuid","snowflake","snowflake-alternative","zero-alloc","zero-allocation"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/mustafaturan/monoton/v2","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mustafaturan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-07T09:01:08.000Z","updated_at":"2025-03-29T14:11:37.000Z","dependencies_parsed_at":"2024-06-18T18:39:48.004Z","dependency_job_id":"c5f33637-bb1a-4e87-bff6-22cbcee05070","html_url":"https://github.com/mustafaturan/monoton","commit_stats":{"total_commits":37,"total_committers":1,"mean_commits":37.0,"dds":0.0,"last_synced_commit":"3496bedc2254538aef51de7864b2838db08b56a4"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/mustafaturan/monoton","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mustafaturan%2Fmonoton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mustafaturan%2Fmonoton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mustafaturan%2Fmonoton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mustafaturan%2Fmonoton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mustafaturan","download_url":"https://codeload.github.com/mustafaturan/monoton/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mustafaturan%2Fmonoton/sbom","scorecard":{"id":668772,"data":{"date":"2025-08-11","repo":{"name":"github.com/mustafaturan/monoton","commit":"d69ed4b3b3653da47d53a2aaa3e37f8c59e1257a"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.1,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/24 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"CII-Best-Practices","score":2,"reason":"badge detected: InProgress","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 12 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-21T19:10:59.692Z","repository_id":45486385,"created_at":"2025-08-21T19:10:59.693Z","updated_at":"2025-08-21T19:10:59.693Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273122203,"owners_count":25049540,"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","status":"online","status_checked_at":"2025-09-01T02:00:09.058Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["go","golang","golang-library","golang-package","id-generator","ksuid","snowflake","snowflake-alternative","zero-alloc","zero-allocation"],"created_at":"2024-12-29T01:03:03.866Z","updated_at":"2025-09-01T12:31:39.349Z","avatar_url":"https://github.com/mustafaturan.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# Monoton\n\n[![Build Status](https://travis-ci.org/mustafaturan/monoton.svg?branch=master)](https://travis-ci.org/mustafaturan/monoton)\n[![Coverage Status](https://coveralls.io/repos/github/mustafaturan/monoton/badge.svg?branch=master)](https://coveralls.io/github/mustafaturan/monoton?branch=main)\n[![Go Report Card](https://goreportcard.com/badge/github.com/mustafaturan/monoton)](https://goreportcard.com/report/github.com/mustafaturan/monoton)\n[![GoDoc](https://godoc.org/github.com/mustafaturan/monoton?status.svg)](https://godoc.org/github.com/mustafaturan/monoton/v3)\n\nHighly scalable, single/multi node, predictable and incremental unique id\ngenerator with zero allocation magic.\n\n## Installation\n\nVia go packages:\n```go get github.com/mustafaturan/monoton/v3```\n\n## API\n\nThe method names and arities/args are stable now. No change should be expected\non the package for the version `3.x.x` except any bug fixes.\n\n## Usage\n\n### Using with Singleton\n\nCreate a new package like below, and then call `Next()` or `NextBytes()` method:\n\n```go\npackage uniqid\n\n// Import packages\nimport (\n\t\"fmt\"\n\t\"github.com/mustafaturan/monoton/v3\"\n\t\"github.com/mustafaturan/monoton/v3/sequencer\"\n)\n\nvar m monoton.Monoton\n\n// On init configure the monoton\nfunc init() {\n\tm = newIDGenerator()\n}\n\nfunc newIDGenerator() monoton.Monoton {\n\t// Fetch your node id from a config server or generate from MAC/IP address\n\tnode := uint64(1)\n\n\t// A unix time value which will be subtracted from the time sequence value.\n\t// The initialTime value type corresponds to the sequencer type's time\n\t// representation. If you are using Millisecond sequencer then it must be\n\t// considered as Millisecond\n\t// If we want to init the time with 2020-01-01 00:00:00 PST\n\tinitialTime := uint64(1577865600000)\n\n\t// Configure monoton with a sequencer and the node\n\tm, err = monoton.New(sequencer.NewMillisecond(), node, initialTime)\n\tif err != nil{\n\t\tpanic(err)\n\t}\n\n\treturn m\n}\n\nfunc Generate() string {\n\tm.Next()\n}\n\nfunc GeneateBytes() [16]byte {\n\tm.NextBytes()\n}\n```\n\nIn any other package generate the ids like below:\n\n```go\nimport (\n\t\"fmt\"\n\t\"uniqid\" // your local uniqid package from your project\n)\n\nfunc main() {\n\tfor i := 0; i \u003c 100; i++ {\n\t\tfmt.Println(uniqid.Generate())\n\t}\n}\n```\n\n### Using with Dependency Injection\n\n```go\npackage main\n\n// Import packages\nimport (\n\t\"fmt\"\n\t\"github.com/mustafaturan/monoton/v3\"\n\t\"github.com/mustafaturan/monoton/v3/sequencer\"\n)\n\nfunc NewIDGenerator() monoton.Monoton {\n\t// Fetch your node id from a config server or generate from MAC/IP address\n\tnode := uint64(1)\n\n\t// A unix time value which will be subtracted from the time sequence value.\n\t// The initialTime value type corresponds to the sequencer type's time\n\t// representation. If you are using Millisecond sequencer then it must be\n\t// considered as Millisecond\n\tinitialTime := uint64(0)\n\n\t// Configure monoton with a sequencer and the node\n\tm, err := monoton.New(sequencer.NewMillisecond(), node, initialTime)\n\tif err != nil{\n\t\tpanic(err)\n\t}\n\n\treturn m\n}\n\nfunc main() {\n\tg := NewIDGenerator()\n\n\tfor i := 0; i \u003c 100; i++ {\n\t\tfmt.Println(g.Next())\n\t}\n}\n```\n\n## Features\n\n### Time Ordered\n\nThe `monoton` package provides sequences based on the `monotonic` time which\nrepresents the absolute elapsed wall-clock time since some arbitrary, fixed\npoint in the past. It isn't affected by changes in the system time-of-day clock.\n\nPlease refer to [ADR 01 - Time](docs/adrs/time.md) for details and consequences.\n\n### Initial Time\n\nInitial time value opens space for time value by subtracting the given value\nfrom the time sequence.\n\n### Readable\n\nThe `monoton` package converts all sequences into `Base62` format. And `Base62`\nonly uses `ASCII` alpha-numeric chars to represent data which makes it easy to\nread, predict the order by a human eye.\n\nThe total byte size is fixed to 16 bytes for all sequencers. And at least one\nbyte is reserved to nodes.\n\nPlease refer to [ADR 02 - Encoding](docs/adrs/encoding.md) for details and\nconsequences.\n\n### Multi Node Support\n\nThe `monoton` package can be used on single/multiple nodes without the need for\nmachine coordination. It uses configured node identifier to generate ids by\nattaching the node identifier to the end of the sequences.\n\n### Extendable\n\nThe package comes with three pre-configured sequencers and `Sequencer` interface\nto allow new sequencers.\n\n#### Included Sequencers and Byte Orderings\n\nThe `monoton` package currently comes with `Nanosecond`, `Millisecond` and\n`Second` sequencers. And it uses `Millisecond` sequencer by default. For each\nsequencer, the byte orders are as following:\n\n```\nSecond:      16 B =\u003e  6 B (seconds)      + 6 B (counter) + 4 B (node)\nMillisecond: 16 B =\u003e  8 B (milliseconds) + 4 B (counter) + 4 B (node)\nNanosecond:  16 B =\u003e 11 B (nanoseconds)  + 2 B (counter) + 3 B (node)\n```\n\nPlease refer to [ADR 03 - Byte Sizes](docs/adrs/byte-sizes.md) for details and\nconsequences.\n\n#### New Sequencers\n\nThe sequencers can be extended for any other time format, sequence format by\nimplementing the `monoton/sequencer.Sequencer` interface.\n\n## Benchmarks\n\nCommand:\n```\ngo test -benchtime 10000000x -benchmem -run=^$ -bench=. github.com/mustafaturan/monoton/v3\n```\n\nResults:\n```\ngoos: darwin\ngoarch: amd64\npkg: github.com/mustafaturan/monoton/v3\ncpu: Intel(R) Core(TM) i5-6267U CPU @ 2.90GHz\nBenchmarkNext-4        \t10000000\t       102.3 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkNextBytes-4   \t10000000\t        97.51 ns/op\t       0 B/op\t       0 allocs/op\nPASS\nok  \tgithub.com/mustafaturan/monoton/v3\t2.203s\n```\n\n## Contributing\n\nAll contributors should follow [Contributing Guidelines](CONTRIBUTING.md) and\n[ADR docs](docs/adrs) before creating pull requests.\n\n## Credits\n\n[Mustafa Turan](https://github.com/mustafaturan)\n\n## License\n\nApache License 2.0\n\nCopyright (c) 2019 Mustafa Turan\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmustafaturan%2Fmonoton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmustafaturan%2Fmonoton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmustafaturan%2Fmonoton/lists"}