Skip to content

Commit 2e32307

Browse files
committed
Merge tag 'v1.0.0-rc.2' into develop
Released v1.0.0-rc.2
2 parents 5d7f081 + c097463 commit 2e32307

File tree

7 files changed

+88
-42
lines changed

7 files changed

+88
-42
lines changed

.travis.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ go:
66
- 1.4
77
- tip
88

9-
before_install:
10-
- wget http://download.rethinkdb.com/dev/2.0.0-0RC1/rethinkdb_2.0.0%2b0RC1~0precise_amd64.deb
11-
- sudo dpkg -i rethinkdb_2.0.0+0RC1~0precise_amd64.deb
9+
cache: apt
1210

1311
before_script:
14-
# - sudo add-apt-repository ppa:rethinkdb/ppa -y
15-
# - sudo apt-get update -q
16-
# - sudo apt-get install rethinkdb
12+
- source /etc/lsb-release && echo "deb http://download.rethinkdb.com/apt $DISTRIB_CODENAME main" | sudo tee /etc/apt/sources.list.d/rethinkdb.list
13+
- wget -qO- http://download.rethinkdb.com/apt/pubkey.gpg | sudo apt-key add -
14+
- sudo apt-get update
15+
- sudo apt-get install rethinkdb
1716
- rethinkdb > /dev/null 2>&1 &
1817
- rethinkdb --port-offset 1 --directory rethinkdb_data1 --join localhost:29016 > /dev/null 2>&1 &
1918
- rethinkdb --port-offset 2 --directory rethinkdb_data2 --join localhost:29016 > /dev/null 2>&1 &

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
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-
## v1.0.0-RC.1 - 2015-06-07
5+
## v1.0.0 RC2 - 2015-06-11
6+
7+
### Fixed
8+
- Fixed issue causing driver to fail when connecting to DB which did not have its canonical address set correctly (#200).
9+
10+
## v1.0.0 RC1 - 2015-06-07
611
In an attempt to make this library more "idiomatic" some functions have been renamed, for the full list of changes see below.
712

813
### Added

README.md

Lines changed: 1 addition & 1 deletion
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: v1.0.0-RC.1 (RethinkDB v2.0)
10+
Current version: v1.0.0 RC2 (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

cluster.go

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,27 @@ func (c *Cluster) connectNodes(hosts []Host) {
206206
continue
207207
}
208208

209-
var results []nodeStatus
210-
err = cursor.All(&results)
211-
if err != nil {
212-
continue
213-
}
209+
if c.opts.DiscoverHosts {
210+
var results []nodeStatus
211+
err = cursor.All(&results)
212+
if err != nil {
213+
continue
214+
}
214215

215-
for _, result := range results {
216-
node, err := c.connectNodeWithStatus(result)
216+
for _, result := range results {
217+
node, err := c.connectNodeWithStatus(result)
218+
if err == nil {
219+
if _, ok := nodeSet[node.ID]; !ok {
220+
log.WithFields(logrus.Fields{
221+
"id": node.ID,
222+
"host": node.Host.String(),
223+
}).Debug("Connected to node")
224+
nodeSet[node.ID] = node
225+
}
226+
}
227+
}
228+
} else {
229+
node, err := c.connectNode(host.String(), []Host{host})
217230
if err == nil {
218231
if _, ok := nodeSet[node.ID]; !ok {
219232
log.WithFields(logrus.Fields{

doc.go

Lines changed: 1 addition & 1 deletion
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: v1.0.0-rc.1 (RethinkDB v2.0)
3+
// Current version: v1.0.0-rc.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

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ func newNode(id string, aliases []Host, cluster *Cluster, pool *Pool) *Node {
4545
}
4646

4747
go func() {
48-
4948
refreshTicker := time.NewTicker(refreshInterval)
5049
for {
5150
select {
@@ -124,7 +123,7 @@ func (n *Node) Query(q Query) (cursor *Cursor, err error) {
124123
n.DecrementHealth()
125124
}
126125

127-
return
126+
return cursor, err
128127
}
129128

130129
// Exec executes a ReQL query using this nodes connection pool.
@@ -138,7 +137,7 @@ func (n *Node) Exec(q Query) (err error) {
138137
n.DecrementHealth()
139138
}
140139

141-
return
140+
return err
142141
}
143142

144143
// Refresh attempts to connect to the node and check that it is still connected
@@ -148,26 +147,52 @@ func (n *Node) Exec(q Query) (err error) {
148147
// the nodes health is decrease, if there were no issues then the node is marked
149148
// as being healthy.
150149
func (n *Node) Refresh() {
151-
cursor, err := n.pool.Query(newQuery(
152-
DB("rethinkdb").Table("server_status").Get(n.ID),
153-
map[string]interface{}{},
154-
n.cluster.opts,
155-
))
156-
if err != nil {
157-
n.DecrementHealth()
158-
return
159-
}
160-
defer cursor.Close()
150+
if n.cluster.opts.DiscoverHosts {
151+
// If host discovery is enabled then check the servers status
152+
cursor, err := n.pool.Query(newQuery(
153+
DB("rethinkdb").Table("server_status").Get(n.ID),
154+
map[string]interface{}{},
155+
n.cluster.opts,
156+
))
157+
if err != nil {
158+
n.DecrementHealth()
159+
return
160+
}
161+
defer cursor.Close()
161162

162-
var status nodeStatus
163-
err = cursor.One(&status)
164-
if err != nil {
165-
return
166-
}
163+
var status nodeStatus
164+
err = cursor.One(&status)
165+
if err != nil {
166+
return
167+
}
167168

168-
if status.Status != "connected" {
169-
n.DecrementHealth()
170-
return
169+
if status.Status != "connected" {
170+
n.DecrementHealth()
171+
return
172+
}
173+
} else {
174+
// If host discovery is disabled just execute a simple ping query
175+
cursor, err := n.pool.Query(newQuery(
176+
Expr("OK"),
177+
map[string]interface{}{},
178+
n.cluster.opts,
179+
))
180+
if err != nil {
181+
n.DecrementHealth()
182+
return
183+
}
184+
defer cursor.Close()
185+
186+
var status string
187+
err = cursor.One(&status)
188+
if err != nil {
189+
return
190+
}
191+
192+
if status != "OK" {
193+
n.DecrementHealth()
194+
return
195+
}
171196
}
172197

173198
// If status check was successful reset health

wercker.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1-
box: wercker/golang
1+
box: google/golang
22
# Services
33
services:
4-
- dancannon/rethinkdb@0.4.0
4+
- rethinkdb
55
# Build definition
66
build:
77
# The steps that will be executed on build
88
steps:
9-
- pjvds/setup-go-workspace
9+
- setup-go-workspace
10+
11+
- script:
12+
name: set rethinkdb_url
13+
code: |
14+
export RETHINKDB_URL=$RETHINKDB_PORT_28015_TCP_ADDR
15+
1016
# Gets the dependencies
1117
- script:
1218
name: get dependencies
1319
code: |
14-
cd $WERCKER_SOURCE_DIR
15-
go version
1620
go get ./...
1721
# Build the project
1822
- script:

0 commit comments

Comments
 (0)