Skip to content

Commit

Permalink
Merge branch 'release/v1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
dancannon committed Aug 19, 2015
2 parents 786f12a + 41ae492 commit cff081d
Show file tree
Hide file tree
Showing 39 changed files with 1,283 additions and 499 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
language: go

gobuild_args: -tags='cluster'
gobuild_args: -tags='cluster' -race

go:
- 1.4
- tip
- 1.5

cache: apt

Expand Down
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,33 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## v1.1.0
### Added
- Replaced `UseOutdated` with `ReadMode`
- Added `EmergencyRepair` and `NonVotingReplicaTags` to `ReconfigureOpts`
- Added `Union` as a root term
- Added `Branch` as a root term
- Added `ReadTimeout` and `WriteTimeout` to `RunOpts` and `ExecOpts`
- Exported `github.com/Sirupsen/logrus.Logger` as `Log`
- Added support for encoding maps with non-string keys
- Added 'Round', 'Ceil' and 'Floor' terms
- Added race detector to CI

### Changed
- Changed `Timeout` connect argument to only configure the connection timeout.
- Replaced `Db` with `DB` in `RunOpts` and `ExecOpts` (`Db` still works for now)
- Made `Cursor` and `Session` safe for concurrent use
- Replaced `ErrClusterClosed` with `ErrConnectionClosed`

## Deprecated
- Deprecated `UseOutdated` optional argument
- Deprecated `Db` in `RunOpt`

### Fixed
- Fixed race condition in node pool
- Fixed node refresh issue with RethinkDB 2.1 due to an API change
- Fixed encoding errors not being returned when running queries

## v1.0.0 - 2015-06-27

1.0.0 is finally here, This is the first stable production ready release of GoRethink!
Expand Down
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

**Driver does not currently support RethinkDB 2.1, update coming soon!**

[![GitHub tag](https://img.shields.io/github/tag/dancannon/gorethink.svg?style=flat)](https://github.com/dancannon/gorethink/releases/tag/v1.0.0-rc.3)
[![GitHub tag](https://img.shields.io/github/tag/dancannon/gorethink.svg?style=flat)](https://github.com/dancannon/gorethink/releases)
[![GoDoc](https://godoc.org/github.com/dancannon/gorethink?status.png)](https://godoc.org/github.com/dancannon/gorethink)
[![build status](https://img.shields.io/travis/dancannon/gorethink/master.svg "build status")](https://travis-ci.org/dancannon/gorethink)

[Go](http://golang.org/) driver for [RethinkDB](http://www.rethinkdb.com/)

![GoRethink Logo](https://raw.github.com/wiki/dancannon/gorethink/gopher-and-thinker-s.png "Golang Gopher and RethinkDB Thinker")

Current version: v1.0.0 (RethinkDB v2.0)
Current version: v1.1.0 (RethinkDB v2.1)

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).

Expand Down Expand Up @@ -109,7 +109,7 @@ r.Expr(map[string]interface{}{"a": 1, "b": 2, "c": 3}).Run(session)
```
Get Example
```go
r.Db("database").Table("table").Get("GUID").Run(session)
r.DB("database").Table("table").Get("GUID").Run(session)
```
Map Example (Func)
```go
Expand All @@ -123,7 +123,7 @@ r.Expr([]interface{}{1, 2, 3, 4, 5}).Map(r.Row.Add(1)).Run(session)
```
Between (Optional Args) Example
```go
r.Db("database").Table("table").Between(1, 10, r.BetweenOpts{
r.DB("database").Table("table").Between(1, 10, r.BetweenOpts{
Index: "num",
RightBound: "closed",
}).Run(session)
Expand All @@ -144,7 +144,7 @@ Different result types are returned depending on what function is used to execut
Example:

```go
res, err := r.Db("database").Table("tablename").Get(key).Run(session)
res, err := r.DB("database").Table("tablename").Get(key).Run(session)
if err != nil {
// error
}
Expand Down Expand Up @@ -251,6 +251,12 @@ BenchmarkSequentialSoftWritesParallel10 10000 263

Many functions have examples and are viewable in the godoc, alternatively view some more full features examples on the [wiki](https://github.com/dancannon/gorethink/wiki/Examples).

## Further reading

- [GoRethink Goes 1.0](https://www.compose.io/articles/gorethink-goes-1-0/)
- [Go, RethinkDB & Changefeeds](https://www.compose.io/articles/go-rethinkdb-and-changefeeds-part-1/)
- [Build an IRC bot in Go with RethinkDB changefeeds](http://rethinkdb.com/blog/go-irc-bot/)

## License

Copyright 2013 Daniel Cannon
Expand Down
143 changes: 0 additions & 143 deletions buffer.go

This file was deleted.

33 changes: 22 additions & 11 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (c *Cluster) discover() {

return c.listenForNodeChanges()
}, b, func(err error, wait time.Duration) {
log.Debugf("Error discovering hosts %s, waiting %s", err, wait)
Log.Debugf("Error discovering hosts %s, waiting %s", err, wait)
})
}
}
Expand All @@ -134,11 +134,16 @@ func (c *Cluster) listenForNodeChanges() error {
return err
}

cursor, err := node.Query(newQuery(
q, err := newQuery(
DB("rethinkdb").Table("server_status").Changes(),
map[string]interface{}{},
c.opts,
))
)
if err != nil {
return fmt.Errorf("Error building query %s", err)
}

cursor, err := node.Query(q)
if err != nil {
return err
}
Expand All @@ -165,7 +170,7 @@ func (c *Cluster) listenForNodeChanges() error {
if !c.nodeExists(node) {
c.addNode(node)

log.WithFields(logrus.Fields{
Log.WithFields(logrus.Fields{
"id": node.ID,
"host": node.Host.String(),
}).Debug("Connected to node")
Expand All @@ -191,18 +196,24 @@ func (c *Cluster) connectNodes(hosts []Host) {
for _, host := range hosts {
conn, err := NewConnection(host.String(), c.opts)
if err != nil {
log.Warnf("Error creating connection %s", err.Error())
Log.Warnf("Error creating connection %s", err.Error())
continue
}
defer conn.Close()

_, cursor, err := conn.Query(newQuery(
q, err := newQuery(
DB("rethinkdb").Table("server_status"),
map[string]interface{}{},
c.opts,
))
)
if err != nil {
Log.Warnf("Error building query %s", err)
continue
}

_, cursor, err := conn.Query(q)
if err != nil {
log.Warnf("Error fetching cluster status %s", err)
Log.Warnf("Error fetching cluster status %s", err)
continue
}

Expand All @@ -217,7 +228,7 @@ func (c *Cluster) connectNodes(hosts []Host) {
node, err := c.connectNodeWithStatus(result)
if err == nil {
if _, ok := nodeSet[node.ID]; !ok {
log.WithFields(logrus.Fields{
Log.WithFields(logrus.Fields{
"id": node.ID,
"host": node.Host.String(),
}).Debug("Connected to node")
Expand All @@ -229,7 +240,7 @@ func (c *Cluster) connectNodes(hosts []Host) {
node, err := c.connectNode(host.String(), []Host{host})
if err == nil {
if _, ok := nodeSet[node.ID]; !ok {
log.WithFields(logrus.Fields{
Log.WithFields(logrus.Fields{
"id": node.ID,
"host": node.Host.String(),
}).Debug("Connected to node")
Expand Down Expand Up @@ -315,7 +326,7 @@ func (c *Cluster) getSeeds() []Host {
// TODO(dancannon) replace with hostpool
func (c *Cluster) GetRandomNode() (*Node, error) {
if !c.IsConnected() {
return nil, ErrClusterClosed
return nil, ErrNoConnections
}
// Must copy array reference for copy on write semantics to work.
nodeArray := c.GetNodes()
Expand Down
Loading

0 comments on commit cff081d

Please sign in to comment.