Popularity
1.1
Growing
Activity
0.3
-
11
1
1

Programming language: Go
License: Apache License 2.0
Tags: UUID    

goflake alternatives and similar packages

Based on the "UUID" category.
Alternatively, view goflake alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of goflake or a related project?

Add another 'UUID' Package

README

GOFLAKE

[goflake](./docs/id.png)

GitHub go.mod Go version Github code coverage GitHub repo size GitHub tag (latest by date) GitHub last commit GitHub

Go Docs

A highly scalable, customizable, and serverless unique ID generator for use in distributed systems. Written in GoLang. Inspired by Twitters Snowflake.

GoFlake is a small library that quickly generates unique identifiers in the microservices space that don't require an additional server to operate. It is based off of Twitters Snowflake project.

  • Its criteria are :
    • A check digit
    • An epoch time in Milliseconds
    • A service number
    • A process ID for the machine
    • A sequence number. The Check digit uses 0 by default. The purpose for it is for auditing. You can set the checkdigit to a 1 later if you wish and observe all IDs that were generated with a 1. Use it as an event code if you would like. Its your call.

Running things on the same clock in distributed systems is a tough problem to solve. An Epoch time is used. The Epoch time is set in components/epoch.go . Set an epoch time in milliseconds that you would consider your microservice's Epoch and whenever an object is created the time since then in milliseconds will be generated into the IDs field.

A service number is used to determine where the object created is being used. For example 311 . In my Microservice 3 is for the Comments Service. 1 for the REST protocol. and 1 for the Deployment method - localhost. This can be tailored to your liking. The process ID is the next field and is taken from the machine that is running the service Finally a 5 digit random sequence number adds a 5 character string with : a-z A-Z 0-9

A generated Identifier would look like this : 0-14591498880493-0311-425471-43Que

Installation

Linux:

If you have GoLang installed. Clone the repository, CD into it and :

go run main.go 

This should run an example.

Copy the generator and components packages into your folder. Add them into mod.go to use GoFlake in your microservice. The packages also come with full code coverage.

Usage example

func main () {

    for i := 0; i <= 100; i++ {
        fmt.Println(generator.GenerateIdentifier())
        //will print 100 IDs 
    }

}

Set your options in the generator/generateid.go and then the GenerateIdentifier() function returns a unique identifier.

Additional documentation is available through godoc. http://localhost:6060/pkg and can be found under "Third Party". The Go Reference is available at https://pkg.go.dev/github.com/hart87/goflake

Release History

  • 1.0.0
    • Minimum Viable Product

Meta

James Hart – [email protected]

Distributed under the Apache license. See LICENSE for more information.

https://github.com/hart87/goflake

Contributing

  1. Please submit any pull requests on the master branch. If you add a feature, please submit it with a passing test.

<!-- Markdown link & img dfn's -->


*Note that all licence references and agreements mentioned in the goflake README section above are relevant to that project's source code only.