2020-05-26 14:46:16 +00:00
|
|
|
package spooler
|
|
|
|
|
|
|
|
import (
|
2022-11-22 06:36:48 +00:00
|
|
|
"context"
|
2022-01-21 07:52:12 +00:00
|
|
|
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/admin/repository/eventsourcing/handler"
|
|
|
|
"github.com/zitadel/zitadel/internal/admin/repository/eventsourcing/view"
|
2023-02-27 21:36:43 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/database"
|
2022-11-22 06:36:48 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
|
|
v1 "github.com/zitadel/zitadel/internal/eventstore/v1"
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/eventstore/v1/spooler"
|
2022-11-22 06:36:48 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/static"
|
2020-05-26 14:46:16 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type SpoolerConfig struct {
|
|
|
|
BulkLimit uint64
|
|
|
|
FailureCountUntilSkip uint64
|
2020-07-28 07:42:21 +00:00
|
|
|
ConcurrentWorkers int
|
2022-07-22 10:08:39 +00:00
|
|
|
ConcurrentInstances int
|
2020-05-26 14:46:16 +00:00
|
|
|
Handlers handler.Configs
|
|
|
|
}
|
|
|
|
|
2023-02-27 21:36:43 +00:00
|
|
|
func StartSpooler(ctx context.Context, c SpoolerConfig, es v1.Eventstore, esV2 *eventstore.Eventstore, view *view.View, sql *database.DB, static static.Storage) *spooler.Spooler {
|
2020-05-26 14:46:16 +00:00
|
|
|
spoolerConfig := spooler.Config{
|
2022-07-22 10:08:39 +00:00
|
|
|
Eventstore: es,
|
2022-11-22 06:36:48 +00:00
|
|
|
EventstoreV2: esV2,
|
2023-02-27 21:36:43 +00:00
|
|
|
Locker: &locker{dbClient: sql.DB},
|
2022-07-22 10:08:39 +00:00
|
|
|
ConcurrentWorkers: c.ConcurrentWorkers,
|
|
|
|
ConcurrentInstances: c.ConcurrentInstances,
|
2022-11-22 06:36:48 +00:00
|
|
|
ViewHandlers: handler.Register(ctx, c.Handlers, c.BulkLimit, c.FailureCountUntilSkip, view, es, static),
|
2020-05-26 14:46:16 +00:00
|
|
|
}
|
|
|
|
spool := spoolerConfig.New()
|
|
|
|
spool.Start()
|
|
|
|
return spool
|
|
|
|
}
|