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

@@ -0,0 +1,27 @@
package command
import (
"context"
"github.com/zitadel/zitadel/internal/repository/milestone"
)
// MilestonePushed writes a new event with a new milestone.Aggregate to the eventstore
func (c *Commands) MilestonePushed(
ctx context.Context,
instanceID string,
eventType milestone.PushedEventType,
endpoints []string,
primaryDomain string,
) error {
id, err := c.idGenerator.Next()
if err != nil {
return err
}
pushedEvent, err := milestone.NewPushedEventByType(ctx, eventType, milestone.NewAggregate(id, instanceID, instanceID), endpoints, primaryDomain)
if err != nil {
return err
}
_, err = c.eventstore.Push(ctx, pushedEvent)
return err
}

View File

@@ -1,25 +0,0 @@
package command
import (
"context"
"github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/repository/milestone"
)
// ReportMilestoneReached writes each *milestone.ReachedEvent directly to the event store
func (c *Commands) ReportMilestoneReached(ctx context.Context, triggeringEvent eventstore.Event, customContext interface{}) error {
aggregateId, err := c.idGenerator.Next()
if err != nil {
return err
}
_, err = c.eventstore.Push(ctx, milestone.NewReachedEvent(ctx, aggregateId, triggeringEvent, customContext))
return err
}
// ReportMilestonePushed defers a milestone.PushedEvent for each *milestone.ReachedEvent and writes it directly to the event store.
func (c *Commands) ReportMilestonePushed(ctx context.Context, endpoints []string, reachedEvent *milestone.ReachedEvent) error {
_, err := c.eventstore.Push(ctx, milestone.NewPushedEvent(ctx, reachedEvent, endpoints))
return err
}