Skip to content

Commit

Permalink
feat: add VbID to couchbase event (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
ErdincOzdemir authored Jan 12, 2024
1 parent dfa5a3b commit db2be75
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 @@ -49,11 +49,11 @@ func (c *connector) listener(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.Cas, event.EventTime)
e = couchbase.NewMutateEvent(event.Key, event.Value, event.CollectionName, event.Cas, event.EventTime, event.VbID)
case models.DcpExpiration:
e = couchbase.NewExpireEvent(event.Key, nil, event.CollectionName, event.Cas, event.EventTime)
e = couchbase.NewExpireEvent(event.Key, nil, event.CollectionName, event.Cas, event.EventTime, event.VbID)
case models.DcpDeletion:
e = couchbase.NewDeleteEvent(event.Key, nil, event.CollectionName, event.Cas, event.EventTime)
e = couchbase.NewDeleteEvent(event.Key, nil, event.CollectionName, event.Cas, event.EventTime, 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, cas uint64, eventTime time.Time) Event {
func NewDeleteEvent(key []byte, value []byte, collectionName string, cas uint64, eventTime time.Time, vbID uint16) Event {
return Event{
Key: key,
Value: value,
IsDeleted: true,
CollectionName: collectionName,
Cas: cas,
EventTime: eventTime,
VbID: vbID,
}
}

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

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

0 comments on commit db2be75

Please sign in to comment.