[GO]go使用etcd
package main import (
"go.etcd.io/etcd/clientv3" //笔者在使用clientv3的时间曾经使用过github.com/coreos/etcd/clientv3这个包,但是会报错,改成这个包就没有问题
"time"
"context"
"fmt"
) func main() {
cli, err := clientv3.New(clientv3.Config{
Endpoints:[]string{"localhost:2379", "localhost:22379", "localhost:32379"},
DialTimeout:*time.Second,
})
if err != nil {
//
}
defer cli.Close() ctx, cancel := context.WithTimeout(context.Background(), *time.Second)
_, err = cli.Put(ctx, "/logagent/conf/", "bbb")
cancel()
if err != nil {
fmt.Println("err:", err)
} ctx, cancel = context.WithTimeout(context.Background(), *time.Second)
resp, err := cli.Get(ctx, "/logagent/conf/")
cancel()
if err != nil {
fmt.Println("get failed, err:", err)
return
}
for _, ev := range resp.Kvs{
fmt.Printf("%s:%s\n", ev.Key, ev.Value)
}
}
[GO]go使用etcd的更多相关文章
- 一次基于etcd的分布式锁自动延时失败问题的排查
今天在测试基于etcd的分布式锁过程中,在测试获取锁后,释放之前超出TTL时长的情况下自动延长TTL这部分功能,在延长指定key的TTL时总是返回404错误信息,在对目标KEY更新TTL时目标KEY已 ...
- etcd:用于服务发现的键值存储系统
etcd是一个高可用的键值存储系统,主要用于共享配置和服务发现.etcd是由CoreOS开发并维护的,灵感来自于 ZooKeeper 和 Doozer,它使用Go语言编写,并通过Raft一致性算法处理 ...
- Centos7下Etcd集群搭建
一.简介 "A highly-available key value store for shared configuration and service discovery." ...
- 通过docker-machine和etcd部署docker swarm集群
本片文章介绍一下 使用docker-machine 搭建docker swarm 集群:docker swarm是docker 官方搭建的容器集群编排工具:容器编排,就是可以使你像使用一太机器一样来使 ...
- etcd第三集
简单说下golang的etcd接口例子.etcd api有v2(http+json)和v3(grpc)两个版本,目前大家都用v2,所以... v2: https://github.com/coreos ...
- etcd第二集
参考文章:https://github.com/coreos/etcd/blob/master/Documentation/v2/api.mdhttp://www.cnblogs.com/zhengr ...
- etcd第一集
网站:https://github.com/coreos/etcd 一些观点:https://yq.aliyun.com/articles/11035 1.etcd是键值存储仓库,配置共享和服务发现2 ...
- etcd命令说明 etcd Version: 3.0.15
etcd Version: 3.0.15Git SHA: fc00305Go Version: go1.6.3Go OS/Arch: linux/amd64 https://github.com/co ...
- etcd api 接口
etcd api接口 基本操作api: https://github.com/coreos/etcd/blob/6acb3d67fbe131b3b2d5d010e00ec80182be4628/Doc ...
- Key/Value存储系统etcd的特性
etcd 是一个高可用的Key/Value存储系统,和其他KV存储系统不同的是,它的灵感来自于 ZooKeeper 和 Doozer,主要用于分享配置和服务发现.利用 etcd 的特性,应用程序可以在 ...
随机推荐
- cocos2dx 分辨率适配问题
分辨率适配问题好文章: http://www.cocoachina.com/bbs/read.php?tid=201987&page=1&toread=1#tpc http://www ...
- erlang和ruby互相调用
erlang调用ruby https://github.com/mojombo/erlectricity ruby调用erlang https://github.com/davebryson/rint ...
- Android Studio failed to create error code -6解决方法
起因是AndroidStudio编译太慢,在stackoverflow上找解决方法,创建了个vm选项文件,导致内存不够用 很多中文博客上都千篇一律地说是内存不够,打开安装路径下bin目录下的studi ...
- Java 字符串拼接 StringBuilder() StringBuffer
字符串拼接 普通方式 public class StringDemo2 { public static void main(String[] args) { // 表示获取从1970- ...
- python3调用阿里云短信服务
#!/usr/bin/env python#-*- coding:utf-8 -*-#Author:lzd import uuidimport datetimeimport hmacimport ba ...
- eclipse+maven springMVC搭建
1.新建项目: 选择Maven Project 选择项目位置,这里我选择的是C:\Users\admin\workspace\practice 选择maven项目类型,这里选择webapp: 填写Gr ...
- 手工编写servlet
index.jsp: <%@ page language="java" import="java.util.*" contentType="te ...
- 国外接活网站Elance, Freelancer和ScriptLance的介绍和对比
国外接活网站Elance, Freelancer和ScriptLance的介绍和对比littleben 一年以前 (via WEB)http://www.geekpark.net/entity/vie ...
- 使用word设置标题级别, 自动生成和大纲对应的多级列表, 自动生成索引目录
作为程序员,只会开发是不够的, 在日常工作中还需要掌握一些办公软件的的操作方法,word excel ppt精通不敢, 暂且入个门吧, 在前后台开发配合过程中,能写的一手好文档将会达到事半功倍的效果, ...
- Electron 前端页面导入jQuery 出现错误Uncaught ReferenceError: jQuery is not defined
如下: <script src="../assets/js/jquery-1.10.2.js"></script> 方法1 改为: <script&g ...