calculate and push 4 in 6 milestones

This commit is contained in:
Elio Bischof
2023-06-28 08:19:34 +02:00
parent 1b5f5e9e62
commit 51a9a54cfd
22 changed files with 667 additions and 229 deletions

View File

@@ -6,6 +6,8 @@ import (
"runtime/debug"
"time"
"github.com/zitadel/zitadel/internal/repository/pseudo"
"github.com/zitadel/logging"
"github.com/zitadel/zitadel/internal/api/authz"
@@ -73,6 +75,7 @@ func NewProjectionHandler(
lock Lock,
unlock Unlock,
initialized <-chan bool,
subscribe bool,
) *ProjectionHandler {
concurrentInstances := int(config.ConcurrentInstances)
if concurrentInstances < 1 {
@@ -97,8 +100,9 @@ func NewProjectionHandler(
go func() {
<-initialized
go h.subscribe(ctx)
if subscribe {
go h.subscribe(ctx)
}
go h.schedule(ctx)
}()
@@ -112,6 +116,13 @@ func (h *ProjectionHandler) Trigger(ctx context.Context, instances ...string) er
if len(instances) > 0 {
ids = instances
}
if h.searchQuery == nil {
return h.processTimestamp(ctx, ids...)
}
return h.processEvents(ctx, ids...)
}
func (h *ProjectionHandler) processEvents(ctx context.Context, ids ...string) error {
for {
events, hasLimitExceeded, err := h.FetchEvents(ctx, ids...)
if err != nil {
@@ -130,6 +141,11 @@ func (h *ProjectionHandler) Trigger(ctx context.Context, instances ...string) er
}
}
func (h *ProjectionHandler) processTimestamp(ctx context.Context, instances ...string) error {
_, err := h.Process(ctx, pseudo.NewTimestampEvent(h.nowFunc(), instances...))
return err
}
// Process handles multiple events by reducing them to statements and updating the projection
func (h *ProjectionHandler) Process(ctx context.Context, events ...eventstore.Event) (index int, err error) {
if len(events) == 0 {