Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection and Cursor can be used concurrently #499

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions connection.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package rethinkdb

import (
"bytes"
"crypto/tls"
"encoding/binary"
"encoding/json"
"fmt"
"net"
"sync"
"sync/atomic"
"time"

"bytes"
"github.com/opentracing/opentracing-go"
"github.com/opentracing/opentracing-go/ext"
"github.com/opentracing/opentracing-go/log"
"golang.org/x/net/context"
p "gopkg.in/rethinkdb/rethinkdb-go.v6/ql2"
"sync"
)

const (
Expand All @@ -41,8 +41,7 @@ type Response struct {
Profile interface{} `json:"p"`
}

// Connection is a connection to a rethinkdb database. Connection is not thread
// safe and should only be accessed be a single goroutine
// Connection is a connection to a RethinkDB database.
type Connection struct {
net.Conn

Expand Down
6 changes: 2 additions & 4 deletions cursor.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ func newCursor(ctx context.Context, conn *Connection, cursorType string, token i
return cursor
}

// Cursor is the result of a query. Its cursor starts before the first row
// of the result set. A Cursor is not thread safe and should only be accessed
// by a single goroutine at any given time. Use Next to advance through the
// rows:
// Cursor is the result of a query. It starts before the first row
// of the result set. Use Next to advance through the rows:
//
// cursor, err := query.Run(session)
// ...
Expand Down
2 changes: 1 addition & 1 deletion pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const (

type connFactory func(host string, opts *ConnectOpts) (*Connection, error)

// A Pool is used to store a pool of connections to a single RethinkDB server
// Pool evenly distributes queries across a set of connections to a RethinkDB server.
type Pool struct {
host Host
opts *ConnectOpts
Expand Down