本文整理匯總了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
}