本文整理汇总了Golang中github.com/cloudfoundry/hm9000/storeadapter.StoreAdapter类的典型用法代码示例。如果您正苦于以下问题:Golang StoreAdapter类的具体用法?Golang StoreAdapter怎么用?Golang StoreAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StoreAdapter类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Walk
func Walk(store storeadapter.StoreAdapter, dirKey string, callback func(storeadapter.StoreNode)) {
nodes, err := store.List(dirKey)
if err != nil {
return
}
for _, node := range nodes {
if node.Key == "/_etcd" {
continue
}
if node.Dir {
Walk(store, node.Key, callback)
} else {
callback(node)
}
}
}
示例2:
. "github.com/cloudfoundry/hm9000/store"
. "github.com/cloudfoundry/hm9000/testhelpers/custommatchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/cloudfoundry/hm9000/config"
"github.com/cloudfoundry/hm9000/models"
"github.com/cloudfoundry/hm9000/storeadapter"
"github.com/cloudfoundry/hm9000/testhelpers/app"
)
var _ = Describe("Desired State", func() {
var (
store Store
etcdAdapter storeadapter.StoreAdapter
conf config.Config
app1 app.App
app2 app.App
app3 app.App
)
BeforeEach(func() {
var err error
conf, err = config.DefaultConfig()
Ω(err).ShouldNot(HaveOccured())
etcdAdapter = storeadapter.NewETCDStoreAdapter(etcdRunner.NodeURLS(), conf.StoreMaxConcurrentRequests)
err = etcdAdapter.Connect()
Ω(err).ShouldNot(HaveOccured())
app1 = app.NewApp()
app2 = app.NewApp()
app3 = app.NewApp()
示例3:
import (
"github.com/cloudfoundry/hm9000/config"
"github.com/cloudfoundry/hm9000/models"
. "github.com/cloudfoundry/hm9000/store"
"github.com/cloudfoundry/hm9000/storeadapter"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"encoding/json"
"time"
)
var _ = Describe("Freshness", func() {
var (
store Store
etcdAdapter storeadapter.StoreAdapter
conf config.Config
)
conf, _ = config.DefaultConfig()
BeforeEach(func() {
etcdAdapter = storeadapter.NewETCDStoreAdapter(etcdRunner.NodeURLS(), conf.StoreMaxConcurrentRequests)
err := etcdAdapter.Connect()
Ω(err).ShouldNot(HaveOccured())
store = NewStore(conf, etcdAdapter)
})
Describe("Bumping freshness", func() {
bumpingFreshness := func(key string, ttl uint64, bump func(store Store, timestamp time.Time) error) {
示例4:
import (
. "github.com/cloudfoundry/hm9000/store"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/cloudfoundry/hm9000/config"
"github.com/cloudfoundry/hm9000/models"
"github.com/cloudfoundry/hm9000/storeadapter"
"github.com/cloudfoundry/hm9000/testhelpers/app"
)
var _ = Describe("Actual State", func() {
var (
store Store
etcdAdapter storeadapter.StoreAdapter
conf config.Config
heartbeat1 models.InstanceHeartbeat
heartbeat2 models.InstanceHeartbeat
heartbeat3 models.InstanceHeartbeat
)
BeforeEach(func() {
var err error
conf, err = config.DefaultConfig()
Ω(err).ShouldNot(HaveOccured())
etcdAdapter = storeadapter.NewETCDStoreAdapter(etcdRunner.NodeURLS(), conf.StoreMaxConcurrentRequests)
err = etcdAdapter.Connect()
Ω(err).ShouldNot(HaveOccured())
a := app.NewApp()
heartbeat1 = a.GetInstance(0).Heartbeat(17)
heartbeat2 = a.GetInstance(1).Heartbeat(12)
示例5:
var numRecords = 512
var storeTypes = []string{"ETCD", "Zookeeper"}
var nodeCounts = []int{1, 3, 5, 7}
var concurrencies = []int{1, 5, 10, 15, 20, 25, 30}
var recordSizes = []int{128, 256, 512, 1024, 2048, 4096}
var _ = Describe("Detailed Store Performance", func() {
for _, storeType := range storeTypes {
storeType := storeType
for _, nodes := range nodeCounts {
nodes := nodes
for _, concurrency := range concurrencies {
concurrency := concurrency
Context(fmt.Sprintf("With %d %s nodes (%d concurrent requests at a time)", nodes, storeType, concurrency), func() {
var storeAdapter storeadapter.StoreAdapter
BeforeEach(func() {
if storeType == "ETCD" {
storeRunner = storerunner.NewETCDClusterRunner(5001, nodes)
storeRunner.Start()
storeAdapter = storeadapter.NewETCDStoreAdapter(storeRunner.NodeURLS(), workerpool.NewWorkerPool(concurrency))
err := storeAdapter.Connect()
Ω(err).ShouldNot(HaveOccured())
} else if storeType == "Zookeeper" {
storeRunner = storerunner.NewZookeeperClusterRunner(2181, nodes)
storeRunner.Start()
storeAdapter = storeadapter.NewZookeeperStoreAdapter(storeRunner.NodeURLS(), workerpool.NewWorkerPool(concurrency), &timeprovider.RealTimeProvider{}, time.Second)
err := storeAdapter.Connect()
示例6:
"github.com/cloudfoundry/hm9000/testhelpers/storerunner"
"fmt"
"time"
)
var storeTypes = []string{"ETCD", "Zookeeper"}
var nodeCounts = []int{1, 3, 5, 7}
var _ = Describe("Store Performance", func() {
for _, storeType := range storeTypes {
storeType := storeType
for _, nodes := range nodeCounts {
nodes := nodes
Context(fmt.Sprintf("With %d %s nodes", nodes, storeType), func() {
var storeAdapter storeadapter.StoreAdapter
BeforeEach(func() {
if storeType == "ETCD" {
storeRunner = storerunner.NewETCDClusterRunner(5001, nodes)
storeRunner.Start()
storeAdapter = storeadapter.NewETCDStoreAdapter(storeRunner.NodeURLS(), 100)
err := storeAdapter.Connect()
Ω(err).ShouldNot(HaveOccured())
} else if storeType == "Zookeeper" {
storeRunner = storerunner.NewZookeeperClusterRunner(2181, nodes)
storeRunner.Start()
storeAdapter = storeadapter.NewZookeeperStoreAdapter(storeRunner.NodeURLS(), 100, &timeprovider.RealTimeProvider{}, time.Second)
err := storeAdapter.Connect()
示例7:
import (
. "github.com/cloudfoundry/hm9000/analyzer"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/cloudfoundry/hm9000/config"
"github.com/cloudfoundry/hm9000/models"
"github.com/cloudfoundry/hm9000/storeadapter"
"github.com/cloudfoundry/hm9000/testhelpers/app"
)
var _ = Describe("Analyzer", func() {
var (
analyzer *Analyzer
etcdStoreAdapter storeadapter.StoreAdapter
conf config.Config
a1 app.App
a2 app.App
)
BeforeEach(func() {
var err error
conf, err = config.DefaultConfig()
Ω(err).ShouldNot(HaveOccured())
etcdStoreAdapter = storeadapter.NewETCDStoreAdapter(etcdRunner.NodeURLS(), conf.StoreMaxConcurrentRequests)
err = etcdStoreAdapter.Connect()
Ω(err).ShouldNot(HaveOccured())
a1 = app.NewApp()
a2 = app.NewApp()
示例8:
package hm_test
import (
"github.com/cloudfoundry/hm9000/config"
. "github.com/cloudfoundry/hm9000/hm"
"github.com/cloudfoundry/hm9000/storeadapter"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Walk", func() {
var etcdStoreAdapter storeadapter.StoreAdapter
BeforeEach(func() {
conf, _ := config.DefaultConfig()
etcdStoreAdapter = storeadapter.NewETCDStoreAdapter(etcdRunner.NodeURLS(), conf.StoreMaxConcurrentRequests)
err := etcdStoreAdapter.Connect()
Ω(err).ShouldNot(HaveOccured())
etcdStoreAdapter.Set([]storeadapter.StoreNode{
storeadapter.StoreNode{Key: "/desired-fresh", Value: []byte("123"), TTL: 0},
storeadapter.StoreNode{Key: "/actual-fresh", Value: []byte("456"), TTL: 0},
storeadapter.StoreNode{Key: "/desired/guid1", Value: []byte("guid1"), TTL: 0},
storeadapter.StoreNode{Key: "/desired/guid2", Value: []byte("guid2"), TTL: 0},
storeadapter.StoreNode{Key: "/menu/oj", Value: []byte("sweet"), TTL: 0},
storeadapter.StoreNode{Key: "/menu/breakfast/pancakes", Value: []byte("tasty"), TTL: 0},
storeadapter.StoreNode{Key: "/menu/breakfast/waffles", Value: []byte("delish"), TTL: 0},
})
})
It("can recurse through keys in the store", func() {
visited := make(map[string]string)