1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
package tests
import (
"log"
"os"
r "gopkg.in/rethinkdb/rethinkdb-go.v6"
)
var sessionEx *r.Session
var urlEx string
func init() {
// If the test is being run by wercker look for the rethink url
urlEx = os.Getenv("RETHINKDB_URL")
if urlEx == "" {
urlEx = "localhost:28015"
}
}
func ExampleConnect() {
var err error
sessionEx, err = r.Connect(r.ConnectOpts{
Address: urlEx,
})
if err != nil {
log.Fatalln(err.Error())
}
}
func ExampleConnect_connectionPool() {
var err error
sessionEx, err = r.Connect(r.ConnectOpts{
Address: urlEx,
InitialCap: 10,
MaxOpen: 10,
})
if err != nil {
log.Fatalln(err.Error())
}
}
func ExampleConnect_cluster() {
var err error
sessionEx, err = r.Connect(r.ConnectOpts{
Addresses: []string{urlEx},
// Addresses: []string{url1, url2, url3, ...},
})
if err != nil {
log.Fatalln(err.Error())
}
}
|