Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bookshelf-writer/pointerfactory
A constructor for standardizing unique pointers within a cluster
https://github.com/bookshelf-writer/pointerfactory
generator go go-module golang library module uid
Last synced: 18 days ago
JSON representation
A constructor for standardizing unique pointers within a cluster
- Host: GitHub
- URL: https://github.com/bookshelf-writer/pointerfactory
- Owner: Bookshelf-Writer
- License: gpl-3.0
- Created: 2024-06-12T14:49:26.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-11-16T03:09:40.000Z (2 months ago)
- Last Synced: 2024-11-16T03:25:20.881Z (2 months ago)
- Topics: generator, go, go-module, golang, library, module, uid
- Language: Shell
- Homepage:
- Size: 65.4 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
![Fork GitHub Release](https://img.shields.io/github/v/release/Bookshelf-Writer/PointerFactory)
![Tests](https://github.com/Bookshelf-Writer/PointerFactory/actions/workflows/go-test.yml/badge.svg)[![Go Report Card](https://goreportcard.com/badge/github.com/Bookshelf-Writer/PointerFactory)](https://goreportcard.com/report/github.com/Bookshelf-Writer/PointerFactory)
![GitHub repo file or directory count](https://img.shields.io/github/directory-file-count/Bookshelf-Writer/PointerFactory?color=orange)
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/Bookshelf-Writer/PointerFactory?color=green)
![GitHub repo size](https://img.shields.io/github/repo-size/Bookshelf-Writer/PointerFactory)# PointerFactory
Library for generating/validating unique UIDs within a cluster## INSTALL
```bash
go get -u github.com/Bookshelf-Writer/PointerFactory
```---
### Generator
- Binding occurs to the date, the reference point is set during initialization
- The allowed number of parallel nodes to maintain uniqueness within the group is 65535
- Within a group, you can receive up to 4294967295 unique pointers per minute
- Multi-stage validation, returning an error at the first occurrence
- There is a checksum (consists of two characters to avoid collisions)
- The maximum allowable size of the number system is 36. The minimum is 2.The maximum length of the generated string does not exceed 20 characters
#### Usage example
```Go
userGroup := 'u'
regGroup := 'r'
commentGroup := 'g'groups := []rune{userGroup, regGroup, commentGroup}
startTime := time.Date(2024, 1, 1, 1, 1, 0, 0, time.UTC)uid, err := New(groups, 0, 36, startTime) //Initialize the factory
if err != nil {
panic(err)
}newUserID, _ := uid.New(userGroup)
newRegID, _ := uid.New(regGroup)
newCommentID, _ := uid.New(commentGroup)fmt.Println(newUserID, newRegID) //Outputs: u09vnb0l9 r09vnb0i6
fmt.Println(uid.IsValid(newCommentID)) //Returns nil since the pointer is valid
uid.Close()
```---
---
### Mirrors
- https://git.bookshelf-writer.fun/Bookshelf-Writer/PointerFactory