Example #1
0
func main() {
	flag.Parse()
	log.SetOutput(os.Stdout)
	log.SetFlags(0)

	clientPolicy = as.NewClientPolicy()
	if *user != "" {
		clientPolicy.User = *user
		clientPolicy.Password = *password
	}

	// connect to the host
	if client, err := as.NewClientWithPolicy(clientPolicy, *host, *port); err != nil {
		log.Fatalln(err.Error())
	} else {
		node := client.GetNodes()[0]
		if conn, err := node.GetConnection(time.Second); err != nil {
			log.Fatalln(err.Error())
		} else {
			if infoMap, err := as.RequestInfo(conn, strings.Trim(*value, " ")); err != nil {
				node.InvalidateConnection(conn)
				log.Fatalln(err.Error())
			} else {
				node.PutConnection(conn)
				cnt := 1
				for k, v := range infoMap {
					log.Printf("%d :  %s\n     %s\n\n", cnt, k, v)
					cnt++
				}
			}
		}
	}
}
Example #2
0
func main() {
	flag.Parse()
	log.SetOutput(os.Stdout)
	log.SetFlags(0)

	clientPolicy = as.NewClientPolicy()
	if *user != "" {
		clientPolicy.User = *user
		clientPolicy.Password = *password
	}
	*value = strings.Trim(*value, " ")

	// connect to the host
	client, err := as.NewClientWithPolicy(clientPolicy, *host, *port)
	dieIfError(err)

	node := client.GetNodes()[0]
	conn, err := node.GetConnection(time.Second)
	dieIfError(err)

	infoMap, err := as.RequestInfo(conn, *value)
	dieIfError(err, func() {
		node.InvalidateConnection(conn)
	})

	node.PutConnection(conn)

	if len(infoMap) == 0 {
		log.Printf("Query successful, no information for -v \"%s\"\n\n", *value)
		return
	}

	outfmt := "%d :  %s\n     %s\n"
	cnt := 1
	for k, v := range infoMap {
		log.Printf(outfmt, cnt, k, v)
		cnt++
	}
}