From 51d5f25b6bcc6186bbb77489aa683fde405cf9b2 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Tue, 12 May 2015 22:40:49 +0200 Subject: [PATCH] client: Add a query example to the package documentation. --- client/client.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/client/client.go b/client/client.go index 3315019..cae5443 100644 --- a/client/client.go +++ b/client/client.go @@ -50,6 +50,25 @@ or: } fmt.Printf("%v\n", res) +or execute queries: + + q, err := client.QueryString("FETCH %s %s", client.Identifier(typ), name) + if err != nil { + // handle error + } + res, err := c.Query(q) + if err != nil { + // handle error + } + + // res is one of the object types defined in the sysdb package. + switch typ { + case "host": + host := res.(*sysdb.Host) + // do something + // ... + } + Each client maintains multiple connections to a SysDB server allowing to handle multiple requests in parallel. The SysDB server is able to handle that easily making it a cheap approach. The low-level Dial function creates a -- 2.30.2