本文整理汇总了Golang中github.com/janelia-flyem/dvid/dvid.Config.SetAll方法的典型用法代码示例。如果您正苦于以下问题:Golang Config.SetAll方法的具体用法?Golang Config.SetAll怎么用?Golang Config.SetAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/janelia-flyem/dvid/dvid.Config
的用法示例。
在下文中一共展示了Config.SetAll方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetTestConfig
// GetTestConfig returns a set of store configurations suitable for testing
// a basholeveldb storage system.
func (e Engine) GetTestConfig() (*storage.Backend, error) {
tc := map[string]interface{}{
"path": fmt.Sprintf("dvid-test-%x", uuid.NewV4().Bytes()),
"testing": true,
}
var c dvid.Config
c.SetAll(tc)
testConfig := map[storage.Alias]dvid.StoreConfig{
"default": dvid.StoreConfig{Config: c, Engine: "basholeveldb"},
}
backend := storage.Backend{
Stores: testConfig,
}
return &backend, nil
}
示例2: Stores
func (c tomlConfig) Stores() (map[storage.Alias]dvid.StoreConfig, error) {
stores := make(map[storage.Alias]dvid.StoreConfig, len(c.Store))
for alias, sc := range c.Store {
e, ok := sc["engine"]
if !ok {
return nil, fmt.Errorf("store configurations must have %q set to valid driver", "engine")
}
engine, ok := e.(string)
if !ok {
return nil, fmt.Errorf("engine set for store %q must be a string", alias)
}
var config dvid.Config
config.SetAll(sc)
stores[alias] = dvid.StoreConfig{
Config: config,
Engine: engine,
}
}
return stores, nil
}
示例3: TestParseConfig
func TestParseConfig(t *testing.T) {
var tc tomlConfig
if _, err := toml.Decode(testConfig, &tc); err != nil {
t.Fatalf("Could not decode TOML config: %v\n", err)
}
sc, ok := tc.Store["kvautobus"]
if !ok {
t.Fatalf("Couldn't find kvautobus config in test\n")
}
var config dvid.Config
config.SetAll(sc)
kvconfig := dvid.StoreConfig{
Config: config,
Engine: "kvautobus",
}
path, timeout, owner, collection, err := parseConfig(kvconfig)
if err != nil {
t.Errorf("Error parsing kvautobus config: %v\n", err)
}
if path != "http://tem-dvid.int.janelia.org:9000" {
t.Errorf("Bad parsing of kvautobus config. Path = %s, not http://tem-dvid.int.janelia.org:9000", path)
}
if timeout != time.Duration(30)*time.Second {
t.Errorf("Expected parsing of kvautobus config: timeout = 30 * time.Second, got %d\n", timeout)
}
if owner != "flyEM" {
t.Errorf("expected owner for kvautobus to be %q, got %q\n", "flyEM", owner)
}
if collection != dvid.UUID("99ef22cd85f143f58a623bd22aad0ef7") {
t.Errorf("expected collection for kvautobus to be 99ef22cd85f143f58a623bd22aad0ef7, got %s\n", collection)
}
}