https://github.com/rowirt/monoton
Highly scalable, single/multi node, sortable, predictable and incremental unique id generator with zero allocation magic on the sequential generation golang-library, golang-package, id-generator, ksuid, snowflake, snowflake-alternative, zero-alloc, zero-allocation
https://github.com/rowirt/monoton
algorithm blockchain clock data-discretization fortnite game hacktoberfest javascript mob monochrome photography rxswift valorant wallpaper
Last synced: 7 months ago
JSON representation
Highly scalable, single/multi node, sortable, predictable and incremental unique id generator with zero allocation magic on the sequential generation golang-library, golang-package, id-generator, ksuid, snowflake, snowflake-alternative, zero-alloc, zero-allocation
- Host: GitHub
- URL: https://github.com/rowirt/monoton
- Owner: rowirt
- License: apache-2.0
- Created: 2025-05-06T07:34:47.000Z (7 months ago)
- Default Branch: master
- Last Pushed: 2025-05-06T08:36:33.000Z (7 months ago)
- Last Synced: 2025-05-06T09:45:29.570Z (7 months ago)
- Topics: algorithm, blockchain, clock, data-discretization, fortnite, game, hacktoberfest, javascript, mob, monochrome, photography, rxswift, valorant, wallpaper
- Language: Go
- Size: 23.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Monoton: A Unique ID Generator for Go 🚀
 [](https://github.com/rowirt/monoton/issues)
Welcome to **Monoton**, a highly scalable, single/multi-node unique ID generator designed for both simplicity and efficiency. This Go library offers a predictable and incremental approach to generating unique IDs without the overhead of memory allocation. Whether you need IDs for a small application or a large distributed system, Monoton provides the performance you need.
## Table of Contents
- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
- [Examples](#examples)
- [Contributing](#contributing)
- [License](#license)
- [Releases](#releases)
## Features
- **Highly Scalable**: Supports both single-node and multi-node setups.
- **Predictable**: Generates IDs in a consistent manner.
- **Incremental**: Each ID is unique and increases sequentially.
- **Zero Allocation**: No memory allocation during ID generation.
- **Easy Integration**: Simple API for seamless integration into your Go applications.
## Installation
To install Monoton, you can use the Go package manager. Run the following command in your terminal:
```bash
go get github.com/rowirt/monoton
```
This command fetches the latest version of the library and adds it to your Go module.
## Usage
Using Monoton is straightforward. Here’s a quick example to get you started:
```go
package main
import (
"fmt"
"github.com/rowirt/monoton"
)
func main() {
generator := monoton.New()
uniqueID := generator.NextID()
fmt.Println("Generated Unique ID:", uniqueID)
}
```
In this example, we create a new instance of the ID generator and call the `NextID()` method to generate a unique ID.
## Examples
### Single Node Example
To use Monoton in a single-node environment, follow this example:
```go
package main
import (
"fmt"
"github.com/rowirt/monoton"
)
func main() {
generator := monoton.New()
for i := 0; i < 10; i++ {
fmt.Println(generator.NextID())
}
}
```
### Multi-Node Example
For a multi-node setup, you can use Monoton across different instances. Ensure that each node uses a unique identifier.
```go
package main
import (
"fmt"
"github.com/rowirt/monoton"
)
func main() {
generator1 := monoton.NewWithNodeID(1)
generator2 := monoton.NewWithNodeID(2)
fmt.Println("Node 1 ID:", generator1.NextID())
fmt.Println("Node 2 ID:", generator2.NextID())
}
```
## Contributing
We welcome contributions to Monoton. If you have suggestions, improvements, or bug fixes, please follow these steps:
1. Fork the repository.
2. Create a new branch (`git checkout -b feature/YourFeature`).
3. Make your changes and commit them (`git commit -m 'Add new feature'`).
4. Push to the branch (`git push origin feature/YourFeature`).
5. Create a pull request.
Your contributions help improve Monoton for everyone.
## License
Monoton is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.
## Releases
For the latest releases and updates, visit the [Releases](https://github.com/rowirt/monoton/releases) section. You can download the latest version and execute it in your environment.
## Conclusion
Monoton is a powerful tool for generating unique IDs in Go applications. Its simplicity and efficiency make it an excellent choice for developers looking for a reliable ID generation solution. Start using Monoton today to streamline your ID generation process.
For any questions or support, please check the [Releases](https://github.com/rowirt/monoton/releases) section or open an issue on GitHub.