Guuid 是一款由 Go 語言開發的,基於HTTP的REST的 UUID 生成服務git
Github:https://github.com/dreamans/g...github
UUID(Universally Unique Identifier)全局惟一標識符,是指在一臺機器上生成的數字,它保證對在同一時空中的全部機器都是惟一的。服務器
Guuid使用了服務器主機名、運行的進程ID、時間戳、隨機數、時序元素等一系列元素來保證生成UUID的惟一性。curl
UUID 16 bytes, 構成:ui
$ 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:url
-port 運行端口 -timeout 讀寫超時時間
運行成功:spa
⇨ http server started on [::]:11223
$ 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, "message": "OK", "data": [ "5d1b3abf-5ab2-27cd-0000-00056d61a5e0", "5d1b3abf-5ab2-27cd-0000-000648f72a80", ... ] } 說明: 最多返回1000條記錄
$ curl http://127.0.0.1:11223/get/simple { "code": 200, "message": "OK", "uuid": "5d1b3abf5ab22792000000046b2155a4" }
$ curl http://127.0.0.1:11223/mget/100/simple { "code": 200, "message": "OK", "data": [ "5d1b3abf5ab227cd000000056d61a5e0", "5d1b3abf5ab227cd0000000648f72a80", ... ] }
LVS -> Nginx -> guuid-servercode
upstream guuid_server { server localhost:11211; server localhost:11212; server localhost:11213; } server { listen 80; server_name localhost; location / { proxy_pass http://guuid_server; } }