Skip to content

Commit

Permalink
GOCBC-127: Implement configurable bulk operation timeouts.
Browse files Browse the repository at this point in the history
Change-Id: I85ae3fa908f762ba263d21c63bb3b0c7a8c06cbc
Reviewed-on: http://review.couchbase.org/69851
Reviewed-by: Mark Nunberg <mark.nunberg@couchbase.com>
Tested-by: Brett Lawson <brett19@gmail.com>
  • Loading branch information
brett19 committed Nov 14, 2016
1 parent e2b9757 commit 3ac4356
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 12 additions & 0 deletions bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type Bucket struct {

transcoder Transcoder
opTimeout time.Duration
bulkOpTimeout time.Duration
duraTimeout time.Duration
duraPollTimeout time.Duration
viewTimeout time.Duration
Expand All @@ -40,6 +41,7 @@ func createBucket(cluster *Cluster, config *gocbcore.AgentConfig) (*Bucket, erro
transcoder: &DefaultTranscoder{},

opTimeout: 2500 * time.Millisecond,
bulkOpTimeout: 10000 * time.Millisecond,
duraTimeout: 40000 * time.Millisecond,
duraPollTimeout: 100 * time.Millisecond,
viewTimeout: 75 * time.Second,
Expand All @@ -62,6 +64,16 @@ func (b *Bucket) SetOperationTimeout(timeout time.Duration) {
b.opTimeout = timeout
}

// BulkOperationTimeout returns the maximum amount of time to wait for a bulk op to succeed.
func (b *Bucket) BulkOperationTimeout() time.Duration {
return b.bulkOpTimeout
}

// SetBulkOperationTimeout sets the maxium amount of time to wait for a bulk op to succeed.
func (b *Bucket) SetBulkOperationTimeout(timeout time.Duration) {
b.bulkOpTimeout = timeout
}

// DurabilityTimeout returns the maximum amount of time to wait for durability to succeed.
func (b *Bucket) DurabilityTimeout() time.Duration {
return b.duraTimeout
Expand Down
3 changes: 1 addition & 2 deletions bucket_multi.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package gocb

import (
"github.com/couchbase/gocb/gocbcore"
"time"
)

type bulkOp struct {
Expand All @@ -28,7 +27,7 @@ type BulkOp interface {

// Do execute one or more `BulkOp` items in parallel.
func (b *Bucket) Do(ops []BulkOp) error {
timeoutTmr := gocbcore.AcquireTimer(time.Second * 10)
timeoutTmr := gocbcore.AcquireTimer(b.bulkOpTimeout)

// Make the channel big enough to hold all our ops in case
// we get delayed inside execute (don't want to block the
Expand Down

0 comments on commit 3ac4356

Please sign in to comment.