2020-05-26 14:46:16 +00:00
|
|
|
package spooler
|
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql"
|
2020-08-26 07:56:23 +00:00
|
|
|
"github.com/caos/zitadel/internal/config/systemdefaults"
|
2021-02-23 14:13:04 +00:00
|
|
|
"github.com/caos/zitadel/internal/eventstore/v1"
|
2020-05-26 14:46:16 +00:00
|
|
|
|
|
|
|
"github.com/caos/zitadel/internal/admin/repository/eventsourcing/handler"
|
|
|
|
"github.com/caos/zitadel/internal/admin/repository/eventsourcing/view"
|
2021-02-23 14:13:04 +00:00
|
|
|
"github.com/caos/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
|
|
|
|
}
|
|
|
|
|
2021-02-23 14:13:04 +00:00
|
|
|
func StartSpooler(c SpoolerConfig, es v1.Eventstore, view *view.View, sql *sql.DB, defaults systemdefaults.SystemDefaults) *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,
|
2021-02-22 13:08:47 +00:00
|
|
|
ViewHandlers: handler.Register(c.Handlers, c.BulkLimit, c.FailureCountUntilSkip, view, es, defaults),
|
2020-05-26 14:46:16 +00:00
|
|
|
}
|
|
|
|
spool := spoolerConfig.New()
|
|
|
|
spool.Start()
|
|
|
|
return spool
|
|
|
|
}
|