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"
|
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"
|
|
|
|
"github.com/caos/zitadel/internal/eventstore"
|
|
|
|
"github.com/caos/zitadel/internal/eventstore/spooler"
|
|
|
|
)
|
|
|
|
|
|
|
|
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-22 13:08:47 +00:00
|
|
|
func StartSpooler(c SpoolerConfig, es eventstore.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
|
|
|
|
}
|