Skip to content

Commit

Permalink
feat: add VbID to couchbase event (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
ErdincOzdemir authored Jan 12, 2024
1 parent 7f1bdff commit c8a052d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ func (c *connector) produce(ctx *models.ListenerContext) {
var e couchbase.Event
switch event := ctx.Event.(type) {
case models.DcpMutation:
e = couchbase.NewMutateEvent(event.Key, event.Value, event.CollectionName, event.EventTime, event.Cas)
e = couchbase.NewMutateEvent(event.Key, event.Value, event.CollectionName, event.EventTime, event.Cas, event.VbID)
case models.DcpExpiration:
e = couchbase.NewExpireEvent(event.Key, nil, event.CollectionName, event.EventTime, event.Cas)
e = couchbase.NewExpireEvent(event.Key, nil, event.CollectionName, event.EventTime, event.Cas, event.VbID)
case models.DcpDeletion:
e = couchbase.NewDeleteEvent(event.Key, nil, event.CollectionName, event.EventTime, event.Cas)
e = couchbase.NewDeleteEvent(event.Key, nil, event.CollectionName, event.EventTime, event.Cas, event.VbID)
default:
return
}
Expand Down
10 changes: 7 additions & 3 deletions couchbase/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,44 @@ type Event struct {
Key []byte
Value []byte
Cas uint64
VbID uint16
IsDeleted bool
IsExpired bool
IsMutated bool
}

func NewDeleteEvent(key []byte, value []byte, collectionName string, eventTime time.Time, cas uint64) Event {
func NewDeleteEvent(key []byte, value []byte, collectionName string, eventTime time.Time, cas uint64, vbID uint16) Event {
return Event{
Key: key,
Value: value,
IsDeleted: true,
CollectionName: collectionName,
EventTime: eventTime,
Cas: cas,
VbID: vbID,
}
}

func NewExpireEvent(key []byte, value []byte, collectionName string, eventTime time.Time, cas uint64) Event {
func NewExpireEvent(key []byte, value []byte, collectionName string, eventTime time.Time, cas uint64, vbID uint16) Event {
return Event{
Key: key,
Value: value,
IsExpired: true,
CollectionName: collectionName,
EventTime: eventTime,
Cas: cas,
VbID: vbID,
}
}

func NewMutateEvent(key []byte, value []byte, collectionName string, eventTime time.Time, cas uint64) Event {
func NewMutateEvent(key []byte, value []byte, collectionName string, eventTime time.Time, cas uint64, vbID uint16) Event {
return Event{
Key: key,
Value: value,
IsMutated: true,
CollectionName: collectionName,
EventTime: eventTime,
Cas: cas,
VbID: vbID,
}
}

0 comments on commit c8a052d

Please sign in to comment.