Skip to content

Commit 2097b2a

Browse files
committed
Merge branch 'release/v0.7.2'
2 parents 0fcd578 + a2ffb7d commit 2097b2a

7 files changed

+35
-9
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## v0.7.2 - 2015-05-05
6+
### Added
7+
- Added support for connecting to a server using TLS (#179)
8+
9+
### Fixed
10+
- Fixed issue causing driver to fail to connect to servers with the HTTP admin interface disabled (#181)
11+
- Fixed errors in documentation (#182, #184)
12+
- Fixed RunWrite not closing the cursor (#185)
13+
514
## v0.7.1 - 2015-04-19
615
### Changed
716
- Improved logging of connection errors.

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[Go](http://golang.org/) driver for [RethinkDB](http://www.rethinkdb.com/)
88

99

10-
Current version: v0.7.1 (RethinkDB v2.0)
10+
Current version: v0.7.2 (RethinkDB v2.0)
1111

1212
Please note that this version of the driver only supports versions of RethinkDB using the v0.4 protocol (any versions of the driver older than RethinkDB 2.0 will not work).
1313

@@ -76,7 +76,7 @@ session, err := r.Connect(r.ConnectOpts{
7676
Database: "test",
7777
AuthKey: "14daak1cad13dj",
7878
DiscoverHosts: true,
79-
}, "localhost:28015")
79+
})
8080
if err != nil {
8181
log.Fatalln(err.Error())
8282
}
@@ -140,6 +140,7 @@ res, err := r.Db("database").Table("tablename").Get(key).Run(session)
140140
if err != nil {
141141
// error
142142
}
143+
defer res.Close() // Always ensure you close the cursor to ensure connections are not leaked
143144
```
144145

145146
Cursors have a number of methods available for accessing the query results

connection.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package gorethink
22

33
import (
4+
"crypto/tls"
45
"encoding/binary"
56
"encoding/json"
67
"io"
@@ -49,7 +50,11 @@ func NewConnection(address string, opts *ConnectOpts) (*Connection, error) {
4950
}
5051
// Connect to Server
5152
nd := net.Dialer{Timeout: c.opts.Timeout}
52-
c.conn, err = nd.Dial("tcp", address)
53+
if c.opts.TLSConfig == nil {
54+
c.conn, err = nd.Dial("tcp", address)
55+
} else {
56+
c.conn, err = tls.DialWithDialer(&nd, "tcp", address, c.opts.TLSConfig)
57+
}
5358
if err != nil {
5459
return nil, err
5560
}

doc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Package gorethink implements a Go driver for RethinkDB
22
//
3-
// Current version: v0.7.1 (RethinkDB v2.0)
3+
// Current version: v0.7.2 (RethinkDB v2.0)
44
// For more in depth information on how to use RethinkDB check out the API docs
55
// at http://rethinkdb.com/api
66
package gorethink

node.go

-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ type nodeStatus struct {
191191
Status string `gorethink:"status"`
192192
Network struct {
193193
Hostname string `gorethink:"hostname"`
194-
HTTPAdminPort int64 `gorethink:"http_admin_port"`
195194
ClusterPort int64 `gorethink:"cluster_port"`
196195
ReqlPort int64 `gorethink:"reql_port"`
197196
CanonicalAddresses []struct {

query.go

+14-4
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,21 @@ func (t Term) Run(s *Session, optArgs ...RunOpts) (*Cursor, error) {
202202
// res, err := r.Db("database").Table("table").Insert(doc).RunWrite(sess)
203203
func (t Term) RunWrite(s *Session, optArgs ...RunOpts) (WriteResponse, error) {
204204
var response WriteResponse
205+
205206
res, err := t.Run(s, optArgs...)
206-
if err == nil {
207-
err = res.One(&response)
207+
if err != nil {
208+
return response, err
209+
}
210+
211+
if err = res.One(&response); err != nil {
212+
return response, err
208213
}
209-
return response, err
214+
215+
if err = res.Close(); err != nil {
216+
return response, err
217+
}
218+
219+
return response, nil
210220
}
211221

212222
// ExecOpts inherits its options from RunOpts, the only difference is the
@@ -240,7 +250,7 @@ func (o *ExecOpts) toMap() map[string]interface{} {
240250
// Exec runs the query but does not return the result. Exec will still wait for
241251
// the response to be received unless the NoReply field is true.
242252
//
243-
// res, err := r.Db("database").Table("table").Insert(doc).Exec(sess, r.ExecOpts{
253+
// err := r.Db("database").Table("table").Insert(doc).Exec(sess, r.ExecOpts{
244254
// NoReply: true,
245255
// })
246256
func (t Term) Exec(s *Session, optArgs ...ExecOpts) error {

session.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package gorethink
22

33
import (
4+
"crypto/tls"
45
"time"
56

67
p "github.com/dancannon/gorethink/ql2"
@@ -22,6 +23,7 @@ type ConnectOpts struct {
2223
Database string `gorethink:"database,omitempty"`
2324
AuthKey string `gorethink:"authkey,omitempty"`
2425
Timeout time.Duration `gorethink:"timeout,omitempty"`
26+
TLSConfig *tls.Config `gorethink:"tlsconfig,omitempty"`
2527

2628
MaxIdle int `gorethink:"max_idle,omitempty"`
2729
MaxOpen int `gorethink:"max_open,omitempty"`

0 commit comments

Comments
 (0)