From 710dfda67775a233e6ddd5e0f092afb9bdd47935 Mon Sep 17 00:00:00 2001 From: Charles Dixon Date: Tue, 24 Sep 2019 17:58:13 +0100 Subject: [PATCH] GOCBC-581: Expose functions on MutationToken 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 Tested-by: Charles Dixon --- token.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/token.go b/token.go index 5d8ea471..b9984f29 100644 --- a/token.go +++ b/token.go @@ -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)