Skip to content

Commit

Permalink
GOCBC-581: Expose functions on MutationToken
Browse files Browse the repository at this point in the history
Motivation
----------
For consistency with other SDKs the MutationToken should expose
its fields via functions.

Changes
-------
Add functions to MutationToken.

Change-Id: I3d7d67436ee8095089f9d13618ff124a1c63efe9
Reviewed-on: http://review.couchbase.org/115270
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Charles Dixon <chvckd@gmail.com>
  • Loading branch information
chvck committed Sep 25, 2019
1 parent 03cef49 commit 710dfda
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions token.go
Expand Up @@ -18,6 +18,26 @@ type bucketToken struct {
VbUuid string `json:"vbuuid"`
}

// BucketName returns the name of the bucket that this token belongs to.
func (mt MutationToken) BucketName() string {
return mt.bucketName
}

// PartitionUUID returns the UUID of the vbucket that this token belongs to.
func (mt MutationToken) PartitionUUID() uint64 {
return uint64(mt.token.VbUuid)
}

// PartitionID returns the ID of the vbucket that this token belongs to.
func (mt MutationToken) PartitionID() uint64 {
return uint64(mt.token.VbId)
}

// SequenceNumber returns the sequence number of the vbucket that this token belongs to.
func (mt MutationToken) SequenceNumber() uint64 {
return uint64(mt.token.SeqNo)
}

func (mt bucketToken) MarshalJSON() ([]byte, error) {
info := []interface{}{mt.SeqNo, mt.VbUuid}
return json.Marshal(info)
Expand Down

0 comments on commit 710dfda

Please sign in to comment.