fix(mirror): include fields in mirror projections (#9884)

# Which Problems Are Solved

- fields projections were not projected during mirror

# How the Problems Are Solved

- an extra step during projections was added to mirror the fields 

# Additional Changes

none

# Additional Context

none
This commit is contained in:
Silvan
2025-05-16 10:02:48 +02:00
committed by GitHub
parent dafde7468d
commit e8cefe07a9
2 changed files with 32 additions and 0 deletions

View File

@@ -283,6 +283,13 @@ func execProjections(ctx context.Context, es *eventstore.Eventstore, instances <
continue
}
err = projection.ProjectInstanceFields(ctx)
if err != nil {
logging.WithFields("instance", instance).WithError(err).Info("trigger fields failed")
failedInstances <- instance
continue
}
err = auth_handler.ProjectInstance(ctx)
if err != nil {
logging.WithFields("instance", instance).OnError(err).Info("trigger auth handler failed")

View File

@@ -98,6 +98,7 @@ type projection interface {
var (
projections []projection
fields []*handler.FieldHandler
)
func Create(ctx context.Context, sqlClient *database.DB, es handler.EventStore, config Config, keyEncryptionAlgorithm crypto.EncryptionAlgorithm, certEncryptionAlgorithm crypto.EncryptionAlgorithm, systemUsers map[string]*internal_authz.SystemAPIUser) error {
@@ -176,6 +177,7 @@ func Create(ctx context.Context, sqlClient *database.DB, es handler.EventStore,
OrgDomainVerifiedFields = newFillOrgDomainVerifiedFields(applyCustomConfig(projectionConfig, config.Customizations[fieldsOrgDomainVerified]))
newProjectionsList()
newFieldsList()
return nil
}
@@ -209,6 +211,18 @@ func ProjectInstance(ctx context.Context) error {
return nil
}
func ProjectInstanceFields(ctx context.Context) error {
for i, fieldProjection := range fields {
logging.WithFields("name", fieldProjection.ProjectionName(), "instance", internal_authz.GetInstance(ctx).InstanceID(), "index", fmt.Sprintf("%d/%d", i, len(fields))).Info("starting fields projection")
err := fieldProjection.Trigger(ctx)
if err != nil {
return err
}
logging.WithFields("name", fieldProjection.ProjectionName(), "instance", internal_authz.GetInstance(ctx).InstanceID()).Info("fields projection done")
}
return nil
}
func ApplyCustomConfig(customConfig CustomConfig) handler.Config {
return applyCustomConfig(projectionConfig, customConfig)
}
@@ -236,6 +250,17 @@ func applyCustomConfig(config handler.Config, customConfig CustomConfig) handler
return config
}
// we know this is ugly, but we need to have a singleton slice of all projections
// and are only able to initialize it after all projections are created
// as setup and start currently create them individually, we make sure we get the right one
// will be refactored when changing to new id based projections
func newFieldsList() {
fields = []*handler.FieldHandler{
ProjectGrantFields,
OrgDomainVerifiedFields,
}
}
// we know this is ugly, but we need to have a singleton slice of all projections
// and are only able to initialize it after all projections are created
// as setup and start currently create them individually, we make sure we get the right one