mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 04:57:33 +00:00
fix(eventstore): use decimal, correct mirror (#9906)
back port #9812, #9878, #9881, #9884 --------- Co-authored-by: Livio Spring <livio.a@gmail.com>
This commit is contained in:
@@ -2,6 +2,9 @@ package projection
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/zitadel/logging"
|
||||
|
||||
internal_authz "github.com/zitadel/zitadel/internal/api/authz"
|
||||
"github.com/zitadel/zitadel/internal/crypto"
|
||||
@@ -89,6 +92,7 @@ var (
|
||||
)
|
||||
|
||||
type projection interface {
|
||||
ProjectionName() string
|
||||
Start(ctx context.Context)
|
||||
Init(ctx context.Context) error
|
||||
Trigger(ctx context.Context, opts ...handler.TriggerOpt) (_ context.Context, err error)
|
||||
@@ -97,6 +101,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 {
|
||||
@@ -178,6 +183,7 @@ func Create(ctx context.Context, sqlClient *database.DB, es handler.EventStore,
|
||||
MembershipFields = newFillMembershipFields(applyCustomConfig(projectionConfig, config.Customizations[fieldsMemberships]))
|
||||
|
||||
newProjectionsList()
|
||||
newFieldsList()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -201,7 +207,8 @@ func Start(ctx context.Context) {
|
||||
}
|
||||
|
||||
func ProjectInstance(ctx context.Context) error {
|
||||
for _, projection := range projections {
|
||||
for i, projection := range projections {
|
||||
logging.WithFields("name", projection.ProjectionName(), "instance", internal_authz.GetInstance(ctx).InstanceID(), "index", fmt.Sprintf("%d/%d", i, len(projections))).Info("starting projection")
|
||||
_, err := projection.Trigger(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -210,6 +217,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)
|
||||
}
|
||||
@@ -234,6 +253,19 @@ 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,
|
||||
InstanceDomainFields,
|
||||
MembershipFields,
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
|
Reference in New Issue
Block a user