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

Golang consul.Register函数代码示例

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

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



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

示例1: setupConsul

func (s *ConsulSuite) setupConsul(c *check.C) {
	s.createComposeProject(c, "consul")
	s.composeProject.Start(c)

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

	// wait for consul
	err = utils.Try(60*time.Second, func() error {
		_, err := kv.Exists("test")
		if err != nil {
			return err
		}
		return nil
	})
	c.Assert(err, checker.IsNil)
}
开发者ID:vdemeester,项目名称:traefik,代码行数:27,代码来源:consul_test.go


示例2: NewBgpRouteManager

func NewBgpRouteManager(masterIface string, server net.IP, as string) *BgpRouteManager {
	b := &BgpRouteManager{
		ethIface:     masterIface,
		server:       server,
		neighborlist: map[string]string{},
		asnum:        as,
	}
	consul.Register()
	client := "localhost:8500"
	kv, err := libkv.NewStore(
		store.CONSUL, // or "consul"
		[]string{client},
		&store.Config{
			ConnectionTimeout: 10 * time.Second,
		},
	)
	b.kv = kv
	if err != nil {
		log.Fatal("Cannot create store consul")
	}
	b.neighborkey = "bgpneighbor"
	if exist, _ := kv.Exists(b.neighborkey); exist == false {
		err := b.kv.Put(b.neighborkey, []byte("bgpneighbor"), &store.WriteOptions{IsDir: true})
		if err != nil {
			fmt.Errorf("Something went wrong when initializing key %v", b.neighborkey)
		}
	}
	err = b.kv.Put(b.neighborkey+"/"+server.String(), []byte(as), nil)
	if err != nil {
		log.Errorf("Error trying to put value at key: %v", b.neighborkey)
	}

	return b
}
开发者ID:jc-m,项目名称:ipvlan-docker-plugin,代码行数:34,代码来源:gobgp_routemanager.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) {
	consul.Register()

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


示例6: setupConsulTLS

func (s *ConsulSuite) setupConsulTLS(c *check.C) {
	s.createComposeProject(c, "consul_tls")
	s.composeProject.Start(c)

	consul.Register()
	clientTLS := &provider.ClientTLS{
		CA:                 "resources/tls/ca.cert",
		Cert:               "resources/tls/consul.cert",
		Key:                "resources/tls/consul.key",
		InsecureSkipVerify: true,
	}
	TLSConfig, err := clientTLS.CreateTLSConfig()
	c.Assert(err, checker.IsNil)

	kv, err := libkv.NewStore(
		store.CONSUL,
		[]string{s.composeProject.Container(c, "consul").NetworkSettings.IPAddress + ":8585"},
		&store.Config{
			ConnectionTimeout: 10 * time.Second,
			TLS:               TLSConfig,
		},
	)

	if err != nil {
		c.Fatal("Cannot create store consul")
	}
	s.kv = kv

	// wait for consul
	err = utils.Try(60*time.Second, func() error {
		_, err := kv.Exists("test")
		if err != nil {
			return err
		}
		return nil
	})
	c.Assert(err, checker.IsNil)
}
开发者ID:vdemeester,项目名称:traefik,代码行数:38,代码来源:consul_test.go


示例7: EnableKVStore

func (gc *GetConf) EnableKVStore(opts *KVOptions) (*GetConf, error) {
	switch strings.ToLower(opts.Backend) {
	case "consul":
		// Register consul store to libkv
		consul.Register()
		// Parse config
		c := &store.Config{
			TLS:               opts.KVConfig.TLS,
			ConnectionTimeout: opts.KVConfig.ConnectionTimeout,
			Bucket:            opts.KVConfig.Bucket,
			PersistConnection: opts.KVConfig.PersistConnection,
		}
		if opts.KVConfig.ClientTLS != nil {
			c.ClientTLS = &store.ClientTLSConfig{
				CertFile:   opts.KVConfig.ClientTLS.CertFile,
				KeyFile:    opts.KVConfig.ClientTLS.KeyFile,
				CACertFile: opts.KVConfig.ClientTLS.CACertFile,
			}
		}
		// Initialize a new store with consul
		kv, err := libkv.NewStore(
			store.CONSUL,
			opts.URLs,
			c,
		)
		if err != nil {
			return gc, errors.New("cannot create store consul")
		}
		gc.KVStore = kv
	default:
		return gc, errors.New("unknown backend")
	}

	// Read options from KV Store
	loadFromKV(gc, opts)

	return gc, nil
}
开发者ID:jllopis,项目名称:getconf,代码行数:38,代码来源:kvstore.go


示例8: init

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


示例9: Provide

// Provide allows the provider to provide configurations to traefik
// using the given configuration channel.
func (provider *Consul) Provide(configurationChan chan<- types.ConfigMessage) error {
	provider.StoreType = store.CONSUL
	consul.Register()
	return provider.provide(configurationChan)
}
开发者ID:abhishekamralkar,项目名称:traefik,代码行数:7,代码来源:consul.go


示例10: init

func init() {
	// Register consul store to libkv
	consul.Register()

}
开发者ID:therealbill,项目名称:port-authority,代码行数:5,代码来源:main.go


示例11: CreateStore

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


示例12: registerKVStores

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


示例13: Provide

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


示例14: init

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


示例15: init

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


示例16: init

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang etcd.Register函数代码示例发布时间:2022-05-23
下一篇:
Golang boltdb.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