Skip to content

HTTP based microservice for id generation and resolving

Notifications You must be signed in to change notification settings

ut8ia/id_generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go

Universally Unique Lexicographically Sortable Identifier (ULID) microservice

HTTP based microservice for generation and resolve ULID`s

HTTP wrapper based on https://github.com/oklog/ulid ULID generator

Futures

  • simple GET requests
  • resolve your uid at millesecond via api

Typical use cases :

  • unique identifiers for distributed services
  • unique id of request for tracing request inside your architecture

Why ULID ?

  • sortable
  • short
  • url-safe
  • simple
  • has other implementations

JS version : https://github.com/ulid/javascript

PHP version : https://github.com/robinvdvleuten/php-ulid

Python : https://github.com/valohai/ulid2

Comparison of ID formats

Config example

server:
  host: "0.0.0.0" # default address
  port: 8084 # port 

Examples

Generate new

$  curl -X GET 0.0.0.0:8080/ 

Result : 01E5DHB0VWZ9P2HXN6E4JC3V3Q

Resolve your id as datetime

$  curl -X GET 0.0.0.0:8080/datetime?id=01E5DHB0VWZ9P2HXN6E4JC3V3Q 

Result : 2020-04-08 21:37:48 +0300 EEST

Resolve your id as timestamp

$ curl -X GET 0.0.0.0:8084/timestamp?id=01E5DHB0VWZ9P2HXN6E4JC3V3Q

Result : 1586371068796

Build

For local run :

$ make start

Build of container for Docker

$ make build

Running

Default config path is ./configs/config.yml so you can simply run

$ ./main

You can run N instances with different configs, specifies it in call argument :

$ ./main ./configs/first_config.yml 
....
$ ./hookexec ./configs/second_config.yml 

Logging

Relay stdout to your logfile

$ ./main ./config/config.yml &> ./logs/example.log

About

HTTP based microservice for id generation and resolving

Resources

Stars

Watchers

Forks

Packages

No packages published