mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 01:37:31 +00:00
feat(eventstore): increase parallel write capabilities (#5940)
This implementation increases parallel write capabilities of the eventstore. Please have a look at the technical advisories: [05](https://zitadel.com/docs/support/advisory/a10005) and [06](https://zitadel.com/docs/support/advisory/a10006). The implementation of eventstore.push is rewritten and stored events are migrated to a new table `eventstore.events2`. If you are using cockroach: make sure that the database user of ZITADEL has `VIEWACTIVITY` grant. This is used to query events.
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/zitadel/zitadel/feature"
|
||||
"github.com/zitadel/zitadel/internal/auth/repository/eventsourcing/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/auth/repository/eventsourcing/spooler"
|
||||
auth_handler "github.com/zitadel/zitadel/internal/auth/repository/eventsourcing/handler"
|
||||
auth_view "github.com/zitadel/zitadel/internal/auth/repository/eventsourcing/view"
|
||||
"github.com/zitadel/zitadel/internal/auth_request/repository/cache"
|
||||
"github.com/zitadel/zitadel/internal/command"
|
||||
@@ -13,20 +13,16 @@ import (
|
||||
"github.com/zitadel/zitadel/internal/crypto"
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
eventstore2 "github.com/zitadel/zitadel/internal/eventstore"
|
||||
v1 "github.com/zitadel/zitadel/internal/eventstore/v1"
|
||||
es_spol "github.com/zitadel/zitadel/internal/eventstore/v1/spooler"
|
||||
"github.com/zitadel/zitadel/internal/id"
|
||||
"github.com/zitadel/zitadel/internal/query"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
SearchLimit uint64
|
||||
Spooler spooler.SpoolerConfig
|
||||
Spooler auth_handler.Config
|
||||
}
|
||||
|
||||
type EsRepository struct {
|
||||
spooler *es_spol.Spooler
|
||||
Eventstore v1.Eventstore
|
||||
eventstore.UserRepo
|
||||
eventstore.AuthRequestRepo
|
||||
eventstore.TokenRepo
|
||||
@@ -35,25 +31,19 @@ type EsRepository struct {
|
||||
eventstore.OrgRepository
|
||||
}
|
||||
|
||||
func Start(ctx context.Context, conf Config, systemDefaults sd.SystemDefaults, command *command.Commands, queries *query.Queries, dbClient *database.DB, esV2 *eventstore2.Eventstore, oidcEncryption crypto.EncryptionAlgorithm, userEncryption crypto.EncryptionAlgorithm, allowOrderByCreationDate bool) (*EsRepository, error) {
|
||||
es, err := v1.Start(dbClient, allowOrderByCreationDate)
|
||||
func Start(ctx context.Context, conf Config, systemDefaults sd.SystemDefaults, command *command.Commands, queries *query.Queries, dbClient *database.DB, esV2 *eventstore2.Eventstore, oidcEncryption crypto.EncryptionAlgorithm, userEncryption crypto.EncryptionAlgorithm) (*EsRepository, error) {
|
||||
view, err := auth_view.StartView(dbClient, oidcEncryption, queries, esV2)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
idGenerator := id.SonyFlakeGenerator()
|
||||
|
||||
view, err := auth_view.StartView(dbClient, oidcEncryption, queries, idGenerator, es)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
auth_handler.Register(ctx, conf.Spooler, view, queries)
|
||||
|
||||
authReq := cache.Start(dbClient)
|
||||
|
||||
spool := spooler.StartSpooler(ctx, conf.Spooler, es, esV2, view, dbClient, queries)
|
||||
|
||||
userRepo := eventstore.UserRepo{
|
||||
SearchLimit: conf.SearchLimit,
|
||||
Eventstore: es,
|
||||
Eventstore: esV2,
|
||||
View: view,
|
||||
Query: queries,
|
||||
SystemDefaults: systemDefaults,
|
||||
@@ -64,8 +54,6 @@ func Start(ctx context.Context, conf Config, systemDefaults sd.SystemDefaults, c
|
||||
view,
|
||||
}
|
||||
return &EsRepository{
|
||||
spool,
|
||||
es,
|
||||
userRepo,
|
||||
eventstore.AuthRequestRepo{
|
||||
PrivacyPolicyProvider: queries,
|
||||
@@ -75,7 +63,6 @@ func Start(ctx context.Context, conf Config, systemDefaults sd.SystemDefaults, c
|
||||
OrgViewProvider: queries,
|
||||
AuthRequests: authReq,
|
||||
View: view,
|
||||
Eventstore: es,
|
||||
UserCodeAlg: userEncryption,
|
||||
UserSessionViewProvider: view,
|
||||
UserViewProvider: view,
|
||||
@@ -90,15 +77,15 @@ func Start(ctx context.Context, conf Config, systemDefaults sd.SystemDefaults, c
|
||||
ApplicationProvider: queries,
|
||||
CustomTextProvider: queries,
|
||||
FeatureCheck: feature.NewCheck(esV2),
|
||||
IdGenerator: idGenerator,
|
||||
IdGenerator: id.SonyFlakeGenerator(),
|
||||
},
|
||||
eventstore.TokenRepo{
|
||||
View: view,
|
||||
Eventstore: es,
|
||||
Eventstore: esV2,
|
||||
},
|
||||
eventstore.RefreshTokenRepo{
|
||||
View: view,
|
||||
Eventstore: es,
|
||||
Eventstore: esV2,
|
||||
SearchLimit: conf.SearchLimit,
|
||||
KeyAlgorithm: oidcEncryption,
|
||||
},
|
||||
@@ -109,7 +96,7 @@ func Start(ctx context.Context, conf Config, systemDefaults sd.SystemDefaults, c
|
||||
SearchLimit: conf.SearchLimit,
|
||||
View: view,
|
||||
SystemDefaults: systemDefaults,
|
||||
Eventstore: es,
|
||||
Eventstore: esV2,
|
||||
Query: queries,
|
||||
},
|
||||
}, nil
|
||||
|
Reference in New Issue
Block a user