fix: use current sequence for refetching of events (#5772)

* fix: use current sequence for refetching of events

* fix: use client ids
This commit is contained in:
Livio Spring
2023-04-28 16:28:13 +02:00
committed by GitHub
parent c8c5cf3c5f
commit 458a383de2
28 changed files with 273 additions and 107 deletions

View File

@@ -17,7 +17,7 @@ const (
type Handler interface {
ViewModel() string
EventQuery(instanceIDs []string) (*models.SearchQuery, error)
EventQuery(ctx context.Context, instanceIDs []string) (*models.SearchQuery, error)
Reduce(*models.Event) error
OnError(event *models.Event, err error) error
OnSuccess(instanceIDs []string) error
@@ -26,7 +26,7 @@ type Handler interface {
QueryLimit() uint64
AggregateTypes() []models.AggregateType
CurrentSequence(instanceID string) (uint64, error)
CurrentSequence(ctx context.Context, instanceID string) (uint64, error)
Eventstore() v1.Eventstore
Subscription() *v1.Subscription
@@ -46,7 +46,7 @@ func ReduceEvent(ctx context.Context, handler Handler, event *models.Event) {
).Error("reduce panicked")
}
}()
currentSequence, err := handler.CurrentSequence(event.InstanceID)
currentSequence, err := handler.CurrentSequence(ctx, event.InstanceID)
if err != nil {
logging.WithError(err).Warn("unable to get current sequence")
return
@@ -67,7 +67,7 @@ func ReduceEvent(ctx context.Context, handler Handler, event *models.Event) {
}
for _, unprocessedEvent := range unprocessedEvents {
currentSequence, err := handler.CurrentSequence(unprocessedEvent.InstanceID)
currentSequence, err := handler.CurrentSequence(ctx, unprocessedEvent.InstanceID)
if err != nil {
logging.WithError(err).Warn("unable to get current sequence")
return

View File

@@ -222,7 +222,7 @@ func (s *spooledHandler) process(ctx context.Context, events []*models.Event, wo
}
func (s *spooledHandler) query(ctx context.Context, instanceIDs []string) ([]*models.Event, error) {
query, err := s.EventQuery(instanceIDs)
query, err := s.EventQuery(ctx, instanceIDs)
if err != nil {
return nil, err
}

View File

@@ -35,7 +35,7 @@ func (h *testHandler) AggregateTypes() []models.AggregateType {
return nil
}
func (h *testHandler) CurrentSequence(instanceID string) (uint64, error) {
func (h *testHandler) CurrentSequence(ctx context.Context, instanceID string) (uint64, error) {
return 0, nil
}
@@ -51,7 +51,7 @@ func (h *testHandler) Subscription() *v1.Subscription {
return nil
}
func (h *testHandler) EventQuery(instanceIDs []string) (*models.SearchQuery, error) {
func (h *testHandler) EventQuery(ctx context.Context, instanceIDs []string) (*models.SearchQuery, error) {
if h.queryError != nil {
return nil, h.queryError
}