本文整理汇总了Golang中org/apache/htrace/client.Client.GetServerConf方法的典型用法代码示例。如果您正苦于以下问题:Golang Client.GetServerConf方法的具体用法?Golang Client.GetServerConf怎么用?Golang Client.GetServerConf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org/apache/htrace/client.Client
的用法示例。
在下文中一共展示了Client.GetServerConf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestClientGetServerConf
func TestClientGetServerConf(t *testing.T) {
htraceBld := &MiniHTracedBuilder{Name: "TestClientGetServerConf",
Cnf: map[string]string{
EXAMPLE_CONF_KEY: EXAMPLE_CONF_VALUE,
},
DataDirs: make([]string, 2)}
ht, err := htraceBld.Build()
if err != nil {
t.Fatalf("failed to create datastore: %s", err.Error())
}
defer ht.Close()
var hcl *htrace.Client
hcl, err = htrace.NewClient(ht.ClientConf(), nil)
if err != nil {
t.Fatalf("failed to create client: %s", err.Error())
}
defer hcl.Close()
serverCnf, err2 := hcl.GetServerConf()
if err2 != nil {
t.Fatalf("failed to call GetServerConf: %s", err2.Error())
}
if serverCnf[EXAMPLE_CONF_KEY] != EXAMPLE_CONF_VALUE {
t.Fatalf("unexpected value for %s: %s",
EXAMPLE_CONF_KEY, EXAMPLE_CONF_VALUE)
}
}
示例2: printServerConfJson
// Print information retrieved from an htraced server via /server/conf as JSON
func printServerConfJson(hcl *htrace.Client) int {
cnf, err := hcl.GetServerConf()
if err != nil {
fmt.Println(err.Error())
return EXIT_FAILURE
}
buf, err := json.MarshalIndent(cnf, "", " ")
if err != nil {
fmt.Printf("Error marshalling server conf: %s", err.Error())
return EXIT_FAILURE
}
fmt.Printf("%s\n", string(buf))
return EXIT_SUCCESS
}