摘要:        
使用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
离地最远的星
阅读(1013)
评论(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
离地最远的星
阅读(199)
评论(0)
推荐(0)
        
            
        
        
摘要:        
下载etcd代码然后拷贝到服务器 来自为知笔记(Wiz)    阅读全文
posted @ 2019-12-20 00:44
离地最远的星
阅读(596)
评论(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
离地最远的星
阅读(346)
评论(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
离地最远的星
阅读(125)
评论(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
离地最远的星
阅读(434)
评论(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
离地最远的星
阅读(301)
评论(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
离地最远的星
阅读(180)
评论(0)
推荐(0)
        
            
        
        
摘要:        

评论(0)
推荐(0)
        
            
        
        
摘要:        
package main import ( "github.com/gin-gonic/gin" "net/http" ) type Topic struct { TopicID int } func main() { m := make(map[string]interface{}) m["username"] = "jerry" rout...    阅读全文
posted @ 2019-12-20 00:40
离地最远的星
阅读(165)
评论(0)
推荐(0)
        
 
                     
                    
                 
                    
                
 
         浙公网安备 33010602011771号
浙公网安备 33010602011771号