本文整理汇总了Golang中github.com/docker/libkv/store/zookeeper.Register函数的典型用法代码示例。如果您正苦于以下问题:Golang Register函数的具体用法?Golang Register怎么用?Golang Register使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Register函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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})
}
示例2: 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
}
示例3: New
func New(hosts []string, config *store.Config) (store.Store, error) {
zookeeper.Register()
s, err := libkv.NewStore(
store.ZK,
hosts,
config,
)
if err != nil {
return nil, err
}
return &ZookeeperStorage{
GeneralStorage: general.New(s, string(store.ZK)),
}, nil
}
示例4: Provide
// Provide allows the provider to provide configurations to traefik
// using the given configuration channel.
func (provider *Zookepper) Provide(configurationChan chan<- types.ConfigMessage, pool *safe.Pool, constraints []types.Constraint) error {
provider.storeType = store.ZK
zookeeper.Register()
return provider.provide(configurationChan, pool, constraints)
}
示例5: init
func init() {
etcd.Register()
consul.Register()
zookeeper.Register()
}
示例6: init
func init() {
consul.Register()
zookeeper.Register()
etcd.Register()
boltdb.Register()
}
示例7: Provide
// Provide allows the provider to provide configurations to traefik
// using the given configuration channel.
func (provider *Zookepper) Provide(configurationChan chan<- types.ConfigMessage) error {
provider.storeType = store.ZK
zookeeper.Register()
return provider.provide(configurationChan)
}
示例8: registerKVStores
func registerKVStores() {
consul.Register()
zookeeper.Register()
etcd.Register()
boltdb.Register()
}
示例9: CreateStore
// CreateStore creates the KV store
func (provider *Zookepper) CreateStore() (store.Store, error) {
provider.storeType = store.ZK
zookeeper.Register()
return provider.createStore()
}