Guuid: 由 Go 语言开发的 UUID 生成服务
发布时间:2020-12-16 19:10:14 所属栏目:大数据 来源:网络整理
导读:Guuid 是一款由 Go 语言开发的,基于HTTP的REST的 UUID 生成服务 Github:https://github.com/dreamans/g... UUID(Universally Unique Identifier)全局唯一标识符,是指在一台机器上生成的数字,它保证对在同一时空中的所有机器都是唯一的。 Guuid使用了服务
Guuid 是一款由 Go 语言开发的,基于HTTP的REST的 UUID 生成服务 Github:https://github.com/dreamans/g... UUID(Universally Unique Identifier)全局唯一标识符,是指在一台机器上生成的数字,它保证对在同一时空中的所有机器都是唯一的。 Guuid使用了服务器主机名、运行的进程ID、时间戳、随机数、时序元素等一系列元素来保证生成UUID的唯一性。 UUID 16 bytes,构成:
安装$ go get -u github.com/dreamans/guuid/guuid-server $ cd $GOPATH/src/github.com/dreamans/guuid/guuid-server $ go install 运行$GOPATH/bin/guuid-server -port 11223 -timeout 3 Usage: -port 运行端口 -timeout 读写超时时间 运行成功: ? http server started on [::]:11223 RestAPI
$ curl http://127.0.0.1:11223/get { "code": 200,"message": "OK","uuid": "5d1b3abf-5ab2-2792-0000-00046b2155a4" }
$ curl http://127.0.0.1:11223/mget/100 { "code": 200,"data": [ "5d1b3abf-5ab2-27cd-0000-00056d61a5e0","5d1b3abf-5ab2-27cd-0000-000648f72a80",... ] } 说明: 最多返回1000条记录
$ curl http://127.0.0.1:11223/get/simple { "code": 200,"uuid": "5d1b3abf5ab22792000000046b2155a4" }
$ curl http://127.0.0.1:11223/mget/100/simple { "code": 200,"data": [ "5d1b3abf5ab227cd000000056d61a5e0","5d1b3abf5ab227cd0000000648f72a80",... ] } 部署LVS -> Nginx -> guuid-server
upstream guuid_server { server localhost:11211; server localhost:11212; server localhost:11213; } server { listen 80; server_name localhost; location / { proxy_pass http://guuid_server; } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |