• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang etcd.Register函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/docker/libkv/store/etcd.Register函数的典型用法代码示例。如果您正苦于以下问题:Golang Register函数的具体用法?Golang Register怎么用?Golang Register使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Register函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: SetUpTest

func (s *EtcdSuite) SetUpTest(c *check.C) {
	s.createComposeProject(c, "etcd")
	s.composeProject.Start(c)

	etcd.Register()
	url := s.composeProject.Container(c, "etcd").NetworkSettings.IPAddress + ":2379"
	kv, err := libkv.NewStore(
		store.ETCD,
		[]string{url},
		&store.Config{
			ConnectionTimeout: 10 * time.Second,
		},
	)
	if err != nil {
		c.Fatal("Cannot create store etcd")
	}
	s.kv = kv

	// wait for etcd
	err = utils.Try(60*time.Second, func() error {
		_, err := kv.Exists("test")
		if err != nil {
			return fmt.Errorf("Etcd connection error to %s: %v", url, err)
		}
		return nil
	})
	c.Assert(err, checker.IsNil)
}
开发者ID:vdemeester,项目名称:traefik,代码行数:28,代码来源:etcd_test.go


示例2: NewStore

func NewStore(machines []string, cmd *ServerCommand, keyspace string) *Storage {
	etcd.Register()

	clt, err := libkv.NewStore(store.ETCD, cmd.Config.BackendMachines, &store.Config{})
	if err != nil {
		panic(err)
	}

	_, err = clt.List(keyspace)
	if err != store.ErrKeyNotFound && err != nil {
		log.WithError(err).Fatal("store: Store backend not reachable")
	}

	cfg := client.Config{
		Endpoints: machines,
		Transport: client.DefaultTransport,
		// set timeout per request to fail fast when the target endpoint is unavailable
		HeaderTimeoutPerRequest: time.Second,
	}
	c, err := client.New(cfg)
	if err != nil {
		log.Fatal(err)
	}
	kapi := client.NewKeysAPI(c)

	return &Storage{Client: clt, Kapi: kapi, command: cmd, keyspace: keyspace}
}
开发者ID:ywshz,项目名称:mygods,代码行数:27,代码来源:storage.go


示例3: Init

// Init is exported
func Init() {
	// Register to libkv
	zookeeper.Register()
	consul.Register()
	etcd.Register()

	// Register to internal Swarm discovery service
	discovery.Register("zk", &Discovery{backend: store.ZK})
	discovery.Register("consul", &Discovery{backend: store.CONSUL})
	discovery.Register("etcd", &Discovery{backend: store.ETCD})
}
开发者ID:dhiltgen,项目名称:swarm,代码行数:12,代码来源:kv.go


示例4: provide

func (provider *KvProvider) provide(configurationChan chan<- configMessage) error {
	switch provider.StoreType {
	case store.CONSUL:
		consul.Register()
	case store.ETCD:
		etcd.Register()
	case store.ZK:
		zookeeper.Register()
	case store.BOLTDB:
		boltdb.Register()
	default:
		return errors.New("Invalid kv store: " + string(provider.StoreType))
	}
	kv, err := libkv.NewStore(
		provider.StoreType,
		[]string{provider.Endpoint},
		&store.Config{
			ConnectionTimeout: 30 * time.Second,
			Bucket:            "traefik",
		},
	)
	if err != nil {
		return err
	}
	if _, err := kv.List(""); err != nil {
		return err
	}
	provider.kvclient = kv
	if provider.Watch {
		stopCh := make(chan struct{})
		chanKeys, err := kv.WatchTree(provider.Prefix, stopCh)
		if err != nil {
			return err
		}
		go func() {
			for {
				<-chanKeys
				configuration := provider.loadConfig()
				if configuration != nil {
					configurationChan <- configMessage{string(provider.StoreType), configuration}
				}
				defer close(stopCh)
			}
		}()
	}
	configuration := provider.loadConfig()
	configurationChan <- configMessage{string(provider.StoreType), configuration}
	return nil
}
开发者ID:ahjdzx,项目名称:traefik,代码行数:49,代码来源:kv.go


示例5: New

func New(hosts []string, config *store.Config) (store.Store, error) {
	etcd.Register()

	s, err := libkv.NewStore(
		store.ETCD,
		hosts,
		config,
	)
	if err != nil {
		return nil, err
	}
	return &EtcdStorage{
		GeneralStorage: general.New(s, string(store.ETCD)),
	}, nil
}
开发者ID:JeffChien,项目名称:kvctl,代码行数:15,代码来源:etcd.go


示例6: init

func init() {
	etcd.Register()
	consul.Register()
	zookeeper.Register()
}
开发者ID:snowsnail,项目名称:dkron,代码行数:5,代码来源:store.go


示例7: init

func init() {
	consul.Register()
	zookeeper.Register()
	etcd.Register()
	boltdb.Register()
}
开发者ID:caoyin0727,项目名称:libdatastore,代码行数:6,代码来源:datastore.go


示例8: Provide

// Provide allows the provider to provide configurations to traefik
// using the given configuration channel.
func (provider *Etcd) Provide(configurationChan chan<- types.ConfigMessage, pool *safe.Pool) error {
	provider.storeType = store.ETCD
	etcd.Register()
	return provider.provide(configurationChan, pool)
}
开发者ID:goguardian,项目名称:traefik,代码行数:7,代码来源:etcd.go


示例9: init

func init() {
	// Register to libkv
	consul.Register()
	etcd.Register()
}
开发者ID:xytis,项目名称:polyp,代码行数:5,代码来源:store.go


示例10: registerKVStores

func registerKVStores() {
	consul.Register()
	zookeeper.Register()
	etcd.Register()
	boltdb.Register()
}
开发者ID:vdemeester,项目名称:libnetwork,代码行数:6,代码来源:store.go


示例11: initLibKV

func initLibKV() {
	etcd.Register()
}
开发者ID:mihdih,项目名称:kubernetes-alerts,代码行数:3,代码来源:kubernetes-alerts.go


示例12: init

func init() {
	etcd.Register()
}
开发者ID:sac,项目名称:glusterd2,代码行数:3,代码来源:store.go


示例13: main

func main() {
        fmt.Println("start controller main()")
	etcd_url_ptr := flag.String("etcd", "192.168.3.2:4001", "etcd url")
	flag.Parse()
	fmt.Println("etcd: ", *etcd_url_ptr)

	h := PC_TopoHandler{}
	topo.AddHandler(h)
	topo.Init(*etcd_url_ptr)

	IpContainerMapMutex = &sync.Mutex{}
	IpContainerMap = make(map[string]*topo.ContainerInfo)

	PodContainerListMutex = &sync.Mutex{}
	PodContainerList = make(map[string]bwctl.QoS)

	n := PC_NodeHandler{}
	rest.AddHandler(n)

	//for testing
	pgreq0 := PGNetworkReq{"nginx", 0.4, 0.4, "Low", "Low", "Low", "Low", 0.4, 0.4, "Low", "Low", "Low", "Low"}	 
	PGNetworkReqPool["nginx"] = pgreq0

	netres0 := NodeNetworkRes{"node_0", 0.2, 1.0, "High", "Low", 1.0, 1.0, "High", "Low"}
	netres1 := NodeNetworkRes{"node_1", 0.3, 1.0, "Low", "Low", 0.5, 1.0, "Low", "Low"}
	netres2 := NodeNetworkRes{"node_2", 0.4, 1.0, "Low", "Low", 0.4, 1.0, "Low", "Low"} 
 	netres3 := NodeNetworkRes{"node_3", 0.6, 1.0, "Low", "Low", 0.6, 1.0, "Low", "Low"}
	netres4 := NodeNetworkRes{"node_4", 1.0, 1.0, "Low", "Low", 1.0, 1.0, "Low", "Low"}
	nodeNetworkResPool["node_0"] = netres0
	nodeNetworkResPool["node_1"] = netres1
	nodeNetworkResPool["node_2"] = netres2
	nodeNetworkResPool["node_3"] = netres3
	nodeNetworkResPool["node_4"] = netres4

	go rest.StartControllerRestServer(*etcd_url_ptr)
    
	//scheduler plugin
	go StartPluginRestServer()



	// client := etcd.NewClient([]string{"192.168.3.2:4001"})   //http://127.0.0.1:4001 deploy.sh: K8S_NODE_IP
   
	// parse_appChain()
	//  select{}
	/* for { //waiting for update forever ...
		watchChan := make(chan *etcd.Response)
		go client.Watch("/0/public/appChain", 0, false, watchChan, nil)
		log.Println("Waiting for an update...")
		r := <-watchChan
		log.Printf("Got updated appChain: %s: %s\n", r.Node.Key, r.Node.Value)
		parse_appChain()
	}*/

	// We can register as many backends that are supported by libkv
	etcd.Register()

	client := "192.168.3.2:4001"

	// Initialize a new store with consul	kv, err := libkv.NewStore(
		store.ETCD,
		[]string{client},
		&store.Config{
			ConnectionTimeout: 10*time.Second,
		},
	)
	if err != nil {
		log.Fatal("Cannot create store")
	}

	//for qos testing
	qos_key := "/0/52:54:00:c8:00:ab"	

	qosCtl := []bwctl.QoS{
		{"192.0.0.1","1", "100", "1","all", "add", "1000", "1000", "1000", "1000", "0"},
		{"192.0.0.1","1", "100", "1","default","add", "10", "100", "10", "100", "5"},
		{"192.0.0.1","1", "100", "1","172.17.0.2","add", "500", "500", "700", "700", "0"},
		{"192.0.0.2","2", "102", "2","172.17.0.3", "add","200", "200", "200", "200", "5"},
		{"192.0.0.2","2", "102", "2","172.17.0.4", "add", "200", "200", "200", "200", "7"},
		}

	qos_encode, err := json.Marshal(qosCtl)
	if err != nil {
		log.Fatal(err)
	}

	//resp, err := kapi.Set(context.Background(), "/" + n.Name, string(qos_encode), nil)

	err = kv.Put(qos_key, []byte(qos_encode), nil)
	if err != nil {
		log.Fatal("Error trying to put value at key `", qos_key, "`")
	}

	pair, err := kv.Get(qos_key)
	if err != nil {
		log.Fatal("Error trying accessing value at key `", qos_key, "`")
	}

	fmt.Println("value: ", string(pair.Value))
	//for qos testing end
//.........这里部分代码省略.........
开发者ID:hqzhang,项目名称:Mytest,代码行数:101,代码来源:controller.go


示例14: CreateStore

// CreateStore creates the KV store
func (provider *Etcd) CreateStore() (store.Store, error) {
	provider.storeType = store.ETCD
	etcd.Register()
	return provider.createStore()
}
开发者ID:vdemeester,项目名称:traefik,代码行数:6,代码来源:etcd.go


示例15: init

func init() {
	etcd.Register()
	consul.Register()
}
开发者ID:sgotti,项目名称:stolon,代码行数:4,代码来源:store.go



注:本文中的github.com/docker/libkv/store/etcd.Register函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang zookeeper.Register函数代码示例发布时间:2022-05-23
下一篇:
Golang consul.Register函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap