本文整理汇总了Golang中github.com/cloudfoundry/storeadapter.StoreAdapter.Create方法的典型用法代码示例。如果您正苦于以下问题:Golang StoreAdapter.Create方法的具体用法?Golang StoreAdapter.Create怎么用?Golang StoreAdapter.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/storeadapter.StoreAdapter
的用法示例。
在下文中一共展示了StoreAdapter.Create方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Announce
func Announce(localIP string, ttl time.Duration, config *config.Config, storeAdapter storeadapter.StoreAdapter, logger *gosteno.Logger) chan (chan bool) {
dopplerMetaBytes, err := buildDopplerMeta(localIP, config)
if err != nil {
panic(err)
}
key := fmt.Sprintf("%s/%s/%s/%d", META_ROOT, config.Zone, config.JobName, config.Index)
logger.Debugf("Starting Health Status Updates to Store: %s", key)
node := storeadapter.StoreNode{
Key: key,
Value: dopplerMetaBytes,
TTL: uint64(ttl.Seconds()),
}
// Call to create to make sure node is created before we return
storeAdapter.Create(node)
status, stopChan, err := storeAdapter.MaintainNode(node)
if err != nil {
panic(err)
}
// The status channel needs to be drained to maintain the node within the etcd cluster
go func() {
for stat := range status {
logger.Debugf("Health updates channel pushed %v at time %v", stat, time.Now())
}
}()
return stopChan
}
示例2: AddETCDNode
func AddETCDNode(etcdAdapter storeadapter.StoreAdapter, key string, value string) {
node := storeadapter.StoreNode{
Key: key,
Value: []byte(value),
TTL: uint64(20),
}
etcdAdapter.Create(node)
recvNode, err := etcdAdapter.Get(key)
Expect(err).NotTo(HaveOccurred())
Expect(string(recvNode.Value)).To(Equal(value))
}
示例3:
finder.Stop()
})
getCallbackCount := func() int {
return int(atomic.LoadInt32(callbackCount))
}
getPreferredCount := func() int {
return int(atomic.LoadInt32(preferredCount))
}
testUpdateFinder := func(updatedAddress map[string]string) func() {
return func() {
Context("when a service exists", func() {
JustBeforeEach(func() {
err := storeAdapter.Create(node)
Expect(err).NotTo(HaveOccurred())
finder.Start()
Eventually(finder.AllServers).ShouldNot(HaveLen(0))
Expect(finder.PreferredServers()).NotTo(HaveLen(0))
})
It("updates the service", func() {
err := storeAdapter.Update(updateNode)
Expect(err).NotTo(HaveOccurred())
Eventually(finder.AllServers).Should(Equal(updatedAddress))
Expect(getCallbackCount()).To(Equal(2))
Expect(finder.PreferredServers()).To(Equal(updatedAddress))
Expect(getPreferredCount()).To(Equal(2))
示例4:
})
})
Describe("Loading listener state on startup", func() {
Context("when the store is empty", func() {
It("should not send anything on the output channels", func() {
go listener.Run()
assertNoDataOnChannel(outAddChan)
assertNoDataOnChannel(outRemoveChan)
})
})
Context("when the store has AppServices in it", func() {
BeforeEach(func() {
adapter.Create(buildNode(app1Service1))
adapter.Create(buildNode(app1Service2))
adapter.Create(buildNode(app2Service1))
})
It("should send all the AppServices on the output add channel", func(done Done) {
go listener.Run()
appServices := drainOutgoingChannel(outAddChan, 3)
Expect(appServices).To(ContainElement(app1Service1))
Expect(appServices).To(ContainElement(app1Service2))
Expect(appServices).To(ContainElement(app2Service1))
assertNoDataOnChannel(outRemoveChan)