From: Sebastian Harl Date: Tue, 12 May 2015 20:40:49 +0000 (+0200) Subject: client: Add a query example to the package documentation. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=51d5f25b6bcc6186bbb77489aa683fde405cf9b2;p=sysdb%2Fgo.git client: Add a query example to the package documentation. --- 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