2020-05-26 14:46:16 +00:00
|
|
|
package spooler
|
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql"
|
2022-01-21 07:52:12 +00:00
|
|
|
|
2022-04-26 23:01:45 +00:00
|
|
|
v1 "github.com/zitadel/zitadel/internal/eventstore/v1"
|
|
|
|
"github.com/zitadel/zitadel/internal/static"
|
2020-05-26 14:46:16 +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"
|
|
|
|
"github.com/zitadel/zitadel/internal/eventstore/v1/spooler"
|
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
|
2020-05-26 14:46:16 +00:00
|
|
|
Handlers handler.Configs
|
|
|
|
}
|
|
|
|
|
2022-02-14 16:22:30 +00:00
|
|
|
func StartSpooler(c SpoolerConfig, es v1.Eventstore, view *view.View, sql *sql.DB, static static.Storage, loginPrefix string) *spooler.Spooler {
|
2020-05-26 14:46:16 +00:00
|
|
|
spoolerConfig := spooler.Config{
|
2020-07-28 07:42:21 +00:00
|
|
|
Eventstore: es,
|
|
|
|
Locker: &locker{dbClient: sql},
|
|
|
|
ConcurrentWorkers: c.ConcurrentWorkers,
|
2022-02-14 16:22:30 +00:00
|
|
|
ViewHandlers: handler.Register(c.Handlers, c.BulkLimit, c.FailureCountUntilSkip, view, es, static, loginPrefix),
|
2020-05-26 14:46:16 +00:00
|
|
|
}
|
|
|
|
spool := spoolerConfig.New()
|
|
|
|
spool.Start()
|
|
|
|
return spool
|
|
|
|
}
|