From 60ff52c55ecf21a1a3f1088a65be424dd2ac0889 Mon Sep 17 00:00:00 2001 From: Andy Lindeman Date: Sun, 10 May 2015 16:15:36 -0400 Subject: [PATCH] Allows RethinkDB timeout to be configured --- pkg/adaptor/rethinkdb.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/adaptor/rethinkdb.go b/pkg/adaptor/rethinkdb.go index d374a2e38..583314566 100644 --- a/pkg/adaptor/rethinkdb.go +++ b/pkg/adaptor/rethinkdb.go @@ -41,6 +41,7 @@ type rethinkDbConfig struct { Namespace string `json:"namespace" doc:"rethink namespace to read/write, in the form database.table"` Debug bool `json:"debug" doc:"if true, verbose debugging information is displayed"` Tail bool `json:"tail" doc:"if true, the RethinkDB table will be monitored for changes after copying the namespace"` + Timeout int `json:"timeout" doc:"timeout, in seconds, for connect, read, and write operations to the RethinkDB server; default is 10"` } type rethinkDbChangeNotification struct { @@ -93,11 +94,16 @@ func NewRethinkdb(p *pipe.Pipe, path string, extra Config) (StopStartListener, e } r.debug = conf.Debug - r.client, err = gorethink.Connect(gorethink.ConnectOpts{ + opts := gorethink.ConnectOpts{ Address: r.uri.Host, MaxIdle: 10, Timeout: time.Second * 10, - }) + } + if conf.Timeout > 0 { + opts.Timeout = time.Duration(conf.Timeout) * time.Second + } + + r.client, err = gorethink.Connect(opts) if err != nil { return r, err }