随笔分类 -  Go etcd

摘要:package util import ( "context" "fmt" "go.etcd.io/etcd/clientv3" "time" ) type Service struct { client *clientv3.Client } func NewService() *Service { config := clientv3.Con... 阅读全文
posted @ 2019-12-20 00:50 离地最远的星 阅读(174) 评论(0) 推荐(0) 编辑
摘要:文件比较少比较小的时候使用文件md5值来监控配置文件 来自为知笔记(Wiz) 阅读全文
posted @ 2019-12-20 00:49 离地最远的星 阅读(395) 评论(0) 推荐(0) 编辑
摘要:package util import ( "context" "fmt" "go.etcd.io/etcd/clientv3" "time" ) type Service struct { client *clientv3.Client } func NewService() *Service { config := clientv3.Con... 阅读全文
posted @ 2019-12-20 00:49 离地最远的星 阅读(136) 评论(0) 推荐(0) 编辑
摘要:实现部分 package util import ( "context" "fmt" "go.etcd.io/etcd/clientv3" "time" ) type Service struct { client *clientv3.Client } func NewService() *Service { config := client... 阅读全文
posted @ 2019-12-20 00:48 离地最远的星 阅读(462) 评论(0) 推荐(0) 编辑
摘要:package util import ( "context" "go.etcd.io/etcd/clientv3" "io/ioutil" "net/http" "regexp" "time" ) type Client struct { client *clientv3.Client Services []*Servi... 阅读全文
posted @ 2019-12-20 00:48 离地最远的星 阅读(558) 评论(0) 推荐(0) 编辑
摘要:package util import ( "context" "go.etcd.io/etcd/clientv3" "regexp" "time" ) type Client struct { client *clientv3.Client Services []*ServiceInfo } type ServiceInfo struct... 阅读全文
posted @ 2019-12-20 00:47 离地最远的星 阅读(143) 评论(0) 推荐(0) 编辑
摘要:package util import ( "math/rand" "time" ) type LoadBalance struct { Servers []*ServiceInfo } func NewloadBalance(servers []*ServiceInfo) *LoadBalance { return &LoadBalance{Servers... 阅读全文
posted @ 2019-12-20 00:47 离地最远的星 阅读(87) 评论(0) 推荐(0) 编辑
摘要:平滑重启的第三方库overseer package main import ( "crypto/md5" "encoding/hex" "flag" "fmt" "github.com/jpillora/overseer" "gopkg.in/ini.v1" "io" "log" "net/http" "os" ... 阅读全文
posted @ 2019-12-20 00:46 离地最远的星 阅读(298) 评论(0) 推荐(0) 编辑
摘要:改成动态更新配置文件,如下每五秒重新生成配置文件 confd与etcd的使用 Add keys This guide assumes you have a working etcd, or consul server up and running and the ability to add new keys. /tmp/test-etcd/etcdctl ... 阅读全文
posted @ 2019-12-20 00:46 离地最远的星 阅读(1600) 评论(0) 推荐(0) 编辑
摘要:使用go初步調用etcd package main import ( "context" "go.etcd.io/etcd/clientv3" "time" ) func main() { config := clientv3.Config{ Endpoints: []string{"106.12.72.181:23791", "106.1... 阅读全文
posted @ 2019-12-20 00:45 离地最远的星 阅读(1002) 评论(0) 推荐(0) 编辑
摘要:package main import ( "context" "flag" "fmt" "github.com/gorilla/mux" uuid "github.com/satori/go.uuid" "goetcd/util" "log" "net/http" "os" "os/signal" "str... 阅读全文
posted @ 2019-12-20 00:45 离地最远的星 阅读(194) 评论(0) 推荐(0) 编辑
摘要:下载etcd代码然后拷贝到服务器 来自为知笔记(Wiz) 阅读全文
posted @ 2019-12-20 00:44 离地最远的星 阅读(588) 评论(0) 推荐(0) 编辑
摘要:docker run -d --name etcd1 --network etcdnet --ip 172.25.0.101 -p 23791:2379 -e ETCDCTL_API=3 -v /root/etcd:/etcd etcd:my etcd --config-file /etcd/conf/etcd.yml curl http://localhost:2... 阅读全文
posted @ 2019-12-20 00:44 离地最远的星 阅读(340) 评论(0) 推荐(0) 编辑
摘要:如上存放一些服务的key到etcd中,商品有两个,主要是为了负载均衡的key func NewService() *Service { config := clientv3.Config{ Endpoints: []string{"106.12.72.181:23791", "106.12.72.181:23792"}, DialTimeout... 阅读全文
posted @ 2019-12-20 00:43 离地最远的星 阅读(428) 评论(0) 推荐(0) 编辑
摘要:优雅的启动服务和退出 package main import ( "fmt" "github.com/gorilla/mux" "goetcd/util" "log" "net/http" "os" "os/signal" "strconv" "syscall" ) func main() { router :=... 阅读全文
posted @ 2019-12-20 00:43 离地最远的星 阅读(121) 评论(0) 推荐(0) 编辑
摘要:/go # etcdctl lease grant 200 //设置一个200秒过期的租约 lease 08e86eea8129eb12 granted with TTL(200s) /go # etcdctl lease timetolive 08e86eea8129eb12 //查看该租约的剩余到期时间 lease 08e86eea8129eb12 granted with TTL(2... 阅读全文
posted @ 2019-12-20 00:42 离地最远的星 阅读(288) 评论(0) 推荐(0) 编辑
摘要:因为是在windows上编译的代码,在linux上不可执行,所以需要交叉编译 package main import ( "flag" "gopkg.in/ini.v1" "log" "net/http" "strconv" ) func main() { port := flag.Int("p", 8080, "服务端口") fl... 阅读全文
posted @ 2019-12-20 00:41 离地最远的星 阅读(173) 评论(0) 推荐(0) 编辑
摘要:![image-20191209191301618](C:\Users\AneroKissinger\AppData\Roaming\Typora\typora-user-images\image-20191209191301618.png root@instance-emh5jlpa:~# etcdctl put /user/101/name xiahualou OK root@insta... 阅读全文
posted @ 2019-12-20 00:41 离地最远的星 阅读(306) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示