All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning.
- Revert backoff v4 for gopath compatibility
- Backoff v4
- Reworked cluster discovery
- Fix rare connection goroutine leak
- Reworked and tested new connection pools with multiple queries per connection
- Socket Read- and WriteTimeout replaced with context timeout
- Mock assert fix
- Connection pool fixed initial size
- Changes added offsets
- 2.4 RethinkDB support
- Added JSON tags to ConnectOpts to make it serializable
- Blocking mocks for responses
- Fix Connect documentation
- Added Type to ChangeResponse
- Added bitwise operations support
- Added write hooks support
- Fix noreply queries memory leak due unnecessary for responses
- Moved to rethinkdb organization
- Renamed to rethinkdb-go repo
- Renamed to rethinkdb package
- Rare
Connection
leaks if socket errors occurred - Updated
ql2.proto
file from rethinkdb repo
- Support for independent custom type marshalers
Connection
work with sockets, now only a single goroutine reads from socket.- Optimized threadsafe operations in
Connection
with channels and atomics instead of mutex. - All tests with real db moved to integration folder
- Added support for tracing with
opentracing-go
- Added a brand-new unit tests for
Connection
- Fixed typo at http opts
- Fixed default context timeout if one of config's timeout os omitted
- Added support to cancellation queries and timeouts with
context.Context
passed throughRunOpts
- Fixed import path for
sirupsen/logrus
due to repo was renamed
- Updated Go versions used by CI
- Fixed performance issue caused by lock contention in
IsConnected
(thanks to @ekle)
- Fixed import paths
- Updated Go version used by Travis
Unfortunately this will likely be the last release I plan to work on. This is due to the following reasons:
- Over the last few years while I have spent a lot of time maintaining this driver I have not used it very much for my own personal projects.
- My job has been keeping me very busy lately and I don't have as much time to work on this project as I used to.
- The company behind RethinkDB has shut down and while I am sure the community will keep the database going it seems like a good time for me to step away from the project.
- The driver itself is in a relatively good condition and many companies are using the existing version in production.
I hope you understand my decision to step back from the project, if you have any questions or would be interested in take over some of the maintenance of the project please let me know. To make this process easier I have also decided to move the repository to the RethinkDB-go organisation. All existing imports should still work.
Thanks to everybody who got involved with this project over the last ~4 years and helped out, I have truly enjoyed the time I have spent building this library and I hope both RethinkDB and this driver manage to keep going.
- Moved project to
gorethink
organisation - Fixed behaviour when unmarshaling nil slices
- Fix possible deadlock when calling
Session.Reconnect
- Fixed another bug with panic/infinite loop when closing cursor during reads
- Fixed goroutine leak when calling
Session.Close
- The
gorethink
struct tag is now always checked even after callingSetTags
- Fixed infinite loop in cursor when closed during read
- Added
State
andError
toChangeResponse
- Fixed panic caused by cursor trying to read outstanding responses while closed
- Fixed panic when using mock session
- Added support for optional arguments to
r.JS()
- Added
NonVotingReplicaTags
optional argument toTableCreateOpts
- Added root term
TypeOf
, previously only the method term was supported - Added root version of
Group
terms (Group
,GroupByIndex
,MultiGroup
,MultiGroupByIndex
) - Added root version of
Distinct
- Added root version of
Contains
- Added root version of
Count
- Added root version of
Sum
- Added root version of
Avg
- Added root version of
Min
- Added root version of
MinIndex
- Added root version of
Max
- Added root version of
MaxIndex
- Added
ReadMode
toRunOpts
- Added the
Interface
function to theCursor
which returns a queries result set as aninterface{}
- Added
GroupOpts
type - Added
GetAllOpts
type - Added
MinOpts
/MaxOpts
types - Added
OptArgs
method toTerm
which allows optional arguments to be specified in an alternative way, for example:
r.DB("examples").Table("heroes").GetAll("man_of_steel").OptArgs(r.GetAllOpts{
Index: "code_name",
})
- Added ability to create compound keys from structs, for example:
type User struct {
Company string `rethinkdb:"id[0]"`
Name string `rethinkdb:"id[1]"`
Age int `rethinkdb:"age"`
}
// Creates
{"id": [COMPANY, NAME], "age": AGE}
- Added
Merge
function toencoding
package that decodes data into a value without zeroing it first. - Added
MockAnything
functions to allow mocking of only part of a query (Thanks to @pzduniak)
- Renamed
PrimaryTag
toPrimaryReplicaTag
inReconfigureOpts
- Renamed
NotAtomic
toNonAtomic
inReplaceOpts
andUpdateOpts
- Changed behaviour of function callbacks to allow arguments to be either of type
r.Term
orinterface {}
instead of onlyr.Term
- Changed logging to be disabled by default, to enable logs change the output writer of the logger. For example:
r.Log.Out = os.Stderr
- Fixed
All
not working correctly when the cursor is created byMock
- Fixed
Mock
not matching queries containing functions - Fixed byte arrays not being correctly converted to the BINARY pseudo-type
- Changed behaviour of function callbacks to allow arguments to be either of type
r.Term
orinterface {}
instead of onlyr.Term
- Fixed incorrectly named
Replicas
field inTableCreateOpts
- Fixed broken optional argument
FinalEmit
inFoldOpts
- Fixed bug causing some queries using
r.Row
to fail with the errorCannot use r.row in nested queries.
- Fixed typos in
ConnectOpt
field (and related functions)InitialCap
.
- Added the
InitialCap
field toConnectOpts
to replaceMaxIdle
as the name no longer made sense.
- Improved documentation of ConnectOpts
- Default value for
KeepAlivePeriod
changed from0
to30s
- Deprecated the field
MaxIdle
inConnectOpts
, it has now been replaced byInitialCap
which has the same behaviour as before. Setting both fields will still work until the field is removed in a future version.
- Fixed issue causing changefeeds to hang if no data was received
- Added
session.Database()
which returns the current default database
- Added more documentation
- Fixed
Random()
not being implemented correctly and added tests (Thanks to @bakape for the PR)
- Added ability to mock queries based on the library github.com/stretchr/testify
- Added the
QueryExecutor
interface and changed query runner methods (Run
/Exec
) to accept this type instead of*Session
,Session
will still be accepted as it implements theQueryExecutor
interface. - Added the
NewMock
function to create a mock query executor - Queries can be mocked using
On
andReturn
,Mock
also contains functions for asserting that the required mocked queries were executed. - For more information about how to mock queries see the readme and tests in
mock_test.go
.
- Added the
- Exported the
Build()
function onQuery
andTerm
. - Updated import of
github.com/cenkalti/backoff
togithub.com/cenk/backoff
- Changed
Connect
to return the reason for connections failing (instead of just "no connections were made when creating the session") - Changed how queries are retried internally, previously when a query failed due to an issue with the connection a new connection was picked from the connection pool and the query was retried, now the driver will attempt to retry the query with a new host (and connection). This should make applications connecting to a multi-node cluster more reliable.
- Fixed queries not being retried when using
Query()
, queries are now retried if the request failed due to a bad connection. - Fixed
Cursor
methods panicking if using a nil cursor, please note that you should still always check if your queries return an error.
- Added constants for system database and table names.
- Re-enabled keep alive by default.
- Fixed issue which prevented anonymous
time.Time
values from being encoded when used in a struct. - Fixed panic when attempting to run a query with a nil session
- Added
UnionWithOpts
term which allowsUnion
to be called with optional arguments (such asInterleave
) - Added
IncludeOffsets
andIncludeTypes
optional arguments toChangesOpts
- Added
Conflict
optional argument toInsertOpts
- Fixed error when connecting to database as non-admin user, please note that
DiscoverHosts
will not work with user authentication at this time due to the fact that RethinkDB restricts access to the required system tables.
- RethinkDB-go now uses the v1.0 RethinkDB protocol which supports RethinkDB v2.3 and above. If you are using RethinkDB 2.2 or older please set
HandshakeVersion
when creating a session. For example:
r.Connect(
...
HandshakeVersion: r.HandshakeV0_4,
...
)
- Added support for username/password authentication. To login pass your username and password when creating a session using the
Username
andPassword
fields in theConnectOpts
. - Added the
Grant
term - Added the
Ordered
optional argument toEqJoin
- Added the
Fold
term and examples - Added the
ReadOne
andReadAll
helper functions for quickly executing a query and scanning the result into a variable. For examples see the godocs. - Added the
Peek
andSkip
functions to theCursor
. - Added support for referential arrays in structs
- Added the
Durability
argument toRunOpts
/ExecOpts
- Deprecated the root
Wait
term,r.Table(...).Wait()
should now be used instead. - Deprecated session authentication using
AuthKey
- Fixed issue with
ReconfigureOpts
fieldPrimaryTag
- Fixed panic when closing a connection at the same time as using a changefeed.
- Update imports to correctly use gopkg.in
- Fixed race condition when using anonymous functions
- Fixed IsConflictErr and IsTypeErr panicking when passed nil errors
- RunWrite no longer misformats errors with formatting directives in them
- Added the ability to reference subdocuments when inserting new documents, for more information see the documentation in the readme.
- Added the
SetTags
function which allows RethinkDB-go to override which tags are used when working with structs. For example to support thejson
add the following callSetTags("gorethink", "json")
. - Added helper functions for checking the error type of a write query, this is useful when calling
RunWrite
.- Added
IsConflictErr
which returns true when RethinkDB returns a duplicate key error. - Added
IsTypeErr
which returns true when RethinkDB returns an unexpected type error.
- Added
- Added the
RawQuery
term which can be used to execute a raw JSON query, for more information about this query see the godoc. - Added the
NextResponse
function toCursor
which will return the next raw JSON response in the result set. - Added ability to set the keep alive period by setting the
KeepAlivePeriod
field inConnectOpts
.
- Fixed an issue that could prevent bad connections from being removed from the connection pool.
- Fixed certain connection errors not being returned as
RqlConnectionError
when callingRun
,Exec
orRunWrite
. - Fixed potential dead lock in connection code caused when building the query.
- Fixed race condition in cursor which caused issues when closing a cursor that is in the process of fetching data.
- Added more documentation and examples for
GetAll
.
- Fixed
RunWrite
not defering its call toCursor.Close()
. This could cause issues if an error occurred when decoding the result. - Fixed panic when calling
Error()
on a RethinkDB-gorqlError
.
- Added new error types, the following error types can now be returned:
RQLClientError
,RQLCompileError
,RQLDriverCompileError
,RQLServerCompileError
,RQLAuthError
,RQLRuntimeError
,RQLQueryLogicError
,RQLNonExistenceError
,RQLResourceLimitError
,RQLUserError
,RQLInternalError
,RQLTimeoutError
,RQLAvailabilityError
,RQLOpFailedError
,RQLOpIndeterminateError
,RQLDriverError
,RQLConnectionError
. Please note that some other errors can be returned. - Added
IsConnected
function toSession
.
- Fixed panic when scanning through results caused by incorrect queue implementation.
- Added
UUID
term - Added
Values
term - Added
IncludeInitial
andChangefeedQueueSize
toChangesOpts
- Added
UseJSONNumber
toConnectOpts
which changes the way the JSON unmarshal works when deserializing JSON with interface{}, it's preferred to use json.Number instead float64 as it preserves the original precision. - Added
HostDecayDuration
toConnectOpts
to configure how hosts are selected. For more information see the godoc.
- Timezones from
time.Time
are now stored in the database, before all times were stored as UTC. To convert a gotime.Time
back to UTC you can callt.In(time.UTC)
. - Improved host selection to use
hailocab/go-hostpool
to select nodes based on recent responses and timings. - Changed connection pool to use
fatih/pool
instead of a custom connection pool, this has caused some internal API changes and the behaviour ofMaxIdle
andMaxOpen
has slightly changed. This change was made mostly to make driver maintenance easier.MaxIdle
now configures the initial size of the pool, the name of this field will likely change in the future.- Not setting
MaxOpen
no longer creates an unbounded connection pool per host but instead creates a pool with a maximum capacity of 2 per host.
- Deprecated the option
NodeRefreshInterval
inConnectOpts
- Deprecated
SetMaxIdleConns
andSetMaxOpenConns
, these options should now only be set when creating the session.
- Fixed some type aliases not being correctly encoded when using
Expr
.
- Added root table terms (
r.TableCreate
,r.TableList
andr.TableDrop
)
- Removed
ReadMode
option fromRunOpts
andExecOpts
(incorrectly added in v1.1.0)
- Fixed
Decode
no longer setting pointer to nil on document not found - Fixed panic when
fetchMore
returns an error - Fixed deadlock when closing changefeed
- Fixed stop query incorrectly waiting for response
- Fixed pointers not to be properly decoded
- Fixed pointers not to be properly decoded
- Fixed queries always timing out when Timeout ConnectOpt is set.
- Fixed issue when encoding some maps
- Corrected protobuf import
- Fixed documentation
- Fixed issues with time pseudotype conversion that caused issues with milliseconds
- Replaced
UseOutdated
withReadMode
- Added
EmergencyRepair
andNonVotingReplicaTags
toReconfigureOpts
- Added
Union
as a root term - Added
Branch
as a root term - Added
ReadTimeout
andWriteTimeout
toRunOpts
andExecOpts
- Exported
github.com/Sirupsen/logrus.Logger
asLog
- Added support for encoding maps with non-string keys
- Added 'Round', 'Ceil' and 'Floor' terms
- Added race detector to CI
- Changed
Timeout
connect argument to only configure the connection timeout. - Replaced
Db
withDB
inRunOpts
andExecOpts
(Db
still works for now) - Made
Cursor
andSession
safe for concurrent use - Replaced
ErrClusterClosed
withErrConnectionClosed
- Deprecated
UseOutdated
optional argument - Deprecated
Db
inRunOpt
- 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
1.0.0 is finally here, This is the first stable production ready release of RethinkDB-go!
In an attempt to make this library more "idiomatic" some functions have been renamed, for the full list of changes and bug fixes see below.
- Added more documentation.
- Added
Shards
,Replicas
andPrimaryReplicaTag
optional arguments inTableCreateOpts
. - Added
MultiGroup
andMultiGroupByIndex
which are equivalent to the runninggroup
with themulti
optional argument set to true.
- Renamed
Db
toDB
. - Renamed
DbCreate
toDBCreate
. - Renamed
DbDrop
toDBDrop
. - Renamed
RqlConnectionError
toRQLConnectionError
. - Renamed
RqlDriverError
toRQLDriverError
. - Renamed
RqlClientError
toRQLClientError
. - Renamed
RqlRuntimeError
toRQLRuntimeError
. - Renamed
RqlCompileError
toRQLCompileError
. - Renamed
Js
toJS
. - Renamed
Json
toJSON
. - Renamed
Http
toHTTP
. - Renamed
GeoJson
toGeoJSON
. - Renamed
ToGeoJson
toToGeoJSON
. - Renamed
WriteChanges
toChangeResponse
, this is now a general type and can be used when dealing with changefeeds. - Removed depth limit when encoding values using
Expr
- Fixed issue causing errors when closing a changefeed cursor (#191)
- Fixed issue causing nodes to remain unhealthy when host discovery is disabled (#195)
- Fixed issue causing driver to fail when connecting to DB which did not have its canonical address set correctly (#200).
- Fixed ongoing queries not being properly stopped when closing the cursor.
- Removed
CacheSize
andDataCenter
optional arguments inTableCreateOpts
. - Removed
CacheSize
optional argument fromInsertOpts
- Added support for connecting to a server using TLS (#179)
- Fixed issue causing driver to fail to connect to servers with the HTTP admin interface disabled (#181)
- Fixed errors in documentation (#182, #184)
- Fixed RunWrite not closing the cursor (#185)
- Improved logging of connection errors.
- Fixed bug causing empty times to be inserted into the DB even when the omitempty tag was set.
- Fixed node status refresh loop leaking goroutines.
This release includes support for RethinkDB 2.0 and connecting to clusters. To connect to a cluster you should use the new Addresses
field in ConnectOpts
, for example:
session, err := r.Connect(r.ConnectOpts{
Addresses: []string{"localhost:28015", "localhost:28016"},
})
if err != nil {
log.Fatalln(err.Error())
}
Also added was the ability to read from a cursor using a channel, this is especially useful when using changefeeds. For more information see this gist
cursor, err := r.Table("items").Changes()
ch := make(chan map[string]interface{})
cursor.Listen(ch)
For more details checkout the README and godoc. As always if you have any further questions send me a message on Gitter.
- Added the ability to connect to multiple nodes, queries are then distributed between these nodes. If a node stops responding then queries stop being sent to this node.
- Added the
DiscoverHosts
optional argument toConnectOpts
, when this value istrue
the driver will listen for new nodes added to the cluster. - Added the
Addresses
optional argument toConnectOpts
, this allows the driver to connect to multiple nodes in a cluster. - Added the
IncludeStates
optional argument toChanges
. - Added
MinVal
andMaxVal
which represent the smallest and largest possible values. - Added the
Listen
cursor helper function which publishes database results to a channel. - Added support for optional arguments for the
Wait
function. - Added the
Type
function to theCursor
, by default this value will be "Cursor" unless using a changefeed. - Changed the
IndexesOf
function toOffsetsOf
. - Changed driver to use the v0.4 protocol (used to use v0.3).
- Fixed geometry tests not properly checking the expected results.
- Fixed bug causing nil pointer panics when using an
Unmarshaler
- Fixed dropped millisecond precision if given value is too old
- Add
IdentifierFormat
optarg toTableOpts
(#158)
- Fix struct alignment for ARM and x86-32 builds (#153)
- Fix sprintf format for geometry error message (#157)
- Fix duplicate if block (#159)
- Fix incorrect assertion in decoder tests
- Fixed
writeQuery
being too small when sending large queries
- Reduce GC by using buffers when reading and writing
- Fixed encoding
time.Time
ignoring millseconds - Fixed pointers in structs that implement the
Marshaler
/Unmarshaler
interfaces being ignored
There are some major changes to the driver with this release that are not related to the RethinkDB v1.16 release. Please have a read through them:
- Improvements to result decoding by caching reflection calls.
- Finished implementing the
Marshaler
/Unmarshaler
interfaces - Connection pool overhauled. There were a couple of issues with connections in the previous releases so this release replaces the
fatih/pool
package with a connection pool based on thedatabase/sql
connection pool. - Another change is the removal of the prefetching mechanism as the connection+cursor logic was becoming quite complex and causing bugs, hopefully this will be added back in the near future but for now I am focusing my efforts on ensuring the driver is as stable as possible #130 #137
- Due to the above change the API for connecting has changed slightly (The API is now closer to the
database/sql
API.ConnectOpts
changes:MaxActive
renamed toMaxOpen
IdleTimeout
renamed toTimeout
Cursor
s are now only closed automatically when calling eitherAll
orOne
Exec
now takesExecOpts
instead ofRunOpts
. The only difference is thatExec
has theNoReply
field
With that out the way here are the v1.16 changes:
- Added
Range
which generates all numbers from a given range - Added an optional squash argument to the changes command, which lets the server combine multiple changes to the same document (defaults to true)
- Added new admin functions (
Config
,Rebalance
,Reconfigure
,Status
,Wait
) - Added support for
SUCCESS_ATOM_FEED
- Added
MinIndex
+MaxInde
x functions - Added
ToJSON
function - Updated
WriteResponse
type
Since this release has a lot of changes and although I have tested these changes sometimes things fall through the gaps. If you discover any bugs please let me know and I will try to fix them as soon as possible.
- Fixed empty slices being returned as
[]T(nil)
not[]T{}
#138
- Added geospatial terms (
Circle
,Distance
,Fill
,Geojson
,ToGeojson
,GetIntersecting
,GetNearest
,Includes
,Intersects
,Line
,Point
,Polygon
,PolygonSub
) - Added
UUID
term for generating unique IDs - Added
AtIndex
term, combinesNth
andGetField
- Added the
Geometry
type, see the types package - Updated the
BatchConf
field inRunOpts
, now uses theBatchOpts
type - Removed support for the
FieldMapper
interface
Internal Changes
- Fixed encoding performance issues, greatly improves writes/second
- Updated
Next
to zero the destination value every time it is called.
- Fixed issue causing
Close
to start an infinite loop - Tidied up connection closing logic
- Fixed bug causing Pseudotypes to not be decoded properly (#117)
- Updated github.com/fatih/pool to v2 (#118)
- Updated the driver to support RethinkDB v1.14 (#116)
- Added the Binary data type
- Added the Binary command which takes a
[]byte
orbytes.Buffer{}
as an argument. - Added the
BinaryFormat
optional argument toRunOpts
- Added the
GroupFormat
optional argument toRunOpts
- Added the
ArrayLimit
optional argument toRunOpts
- Renamed the
ReturnVals
optional argument toReturnChanges
- Renamed the
Upsert
optional argument toConflict
- Added the
IndexRename
command - Updated
Distinct
to now take theIndex
optional argument (usingDistinctOpts
)
Internal Changes
- Updated to use the new JSON protocol
- Switched the connection pool code to use github.com/fatih/pool
- Added some benchmarks
- Fixed issue causing connections not to be closed correctly (#109)
- Fixed issue causing terms in optional arguments to be encoded incorrectly (#114)
- Fixed "Token ## not in stream cache" error (#103)
- Changed Exec to no longer use NoReply. It now waits for the server to respond.
- Replaced
ResultRows
/ResultRow
withCursor
,Cursor
has theNext
,All
andOne
methods which stores the relevant value in the value pointed at by result. For more information check the examples. - Changed the time constants (Days and Months) to package globals instead of functions
- Added the
Args
term and changed the arguments for many terms toargs ...interface{}
to allow argument splicing - Added the
Changes
term and support for the feed response type - Added the
Random
term - Added the
Http
term - The second argument for
Slice
is now optional EqJoin
now accepts a function as its first argumentNth
now returns a selection
- Changed
Connect
to useConnectOpts
instead ofmap[string]interface{}
- Migrated to new
Group
/Ungroup
functions, these replaceGroupedMapReduce
andGroupBy
- Added new aggregators
- Removed base parameter for
Reduce
- Added
Object
function - Added
Upcase
,Downcase
andSplit
string functions - Added
GROUPED_DATA
pseudotype - Fixed query printing
- Added noreply writes
- Added the new terms
index_status
,index_wait
andsync
- Added the profile flag to the run functions
- Optional arguments are now structs instead of key, pair strings. Almost all of the struct fields are of type interface{} as they can have terms inside them. For example:
r.TableCreateOpts{ PrimaryKey: r.Expr("index") }
- Returned arrays are now properly loaded into ResultRows. In the past when running
r.Expr([]interface{}{1,2,3})
would require you to useRunRow
followed byScan
. You can now useRun
followed byScanAll