fix: improve context handling in projections (#3638)

* fix: improve context handling in projections

* fix tests

* use as of system time for current sequence

* use as of system time for current sequence

Co-authored-by: Silvan <silvan.reusser@gmail.com>
This commit is contained in:
Livio Amstutz
2022-05-19 10:25:19 +02:00
committed by GitHub
parent ed0aa7088b
commit c71ccc8a80
7 changed files with 47 additions and 21 deletions

View File

@@ -35,7 +35,7 @@ type Lock func(context.Context, time.Duration, string) <-chan error
type Unlock func(string) error
//SearchQuery generates the search query to lookup for events
type SearchQuery func() (query *eventstore.SearchQueryBuilder, queryLimit uint64, err error)
type SearchQuery func(ctx context.Context) (query *eventstore.SearchQueryBuilder, queryLimit uint64, err error)
type ProjectionHandler struct {
Handler
@@ -259,7 +259,7 @@ func (h *ProjectionHandler) fetchBulkStmts(
query SearchQuery,
reduce Reduce,
) (limitExeeded bool, err error) {
eventQuery, eventsLimit, err := query()
eventQuery, eventsLimit, err := query(ctx)
if err != nil {
logging.WithFields("projection", h.ProjectionName).WithError(err).Warn("unable to create event query")
return false, err