2020-05-26 16:46:16 +02:00
|
|
|
package spooler
|
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql"
|
2020-08-26 09:56:23 +02:00
|
|
|
"github.com/caos/zitadel/internal/config/systemdefaults"
|
2021-02-23 15:13:04 +01:00
|
|
|
"github.com/caos/zitadel/internal/eventstore/v1"
|
2020-05-26 16:46:16 +02:00
|
|
|
|
|
|
|
"github.com/caos/zitadel/internal/admin/repository/eventsourcing/handler"
|
|
|
|
"github.com/caos/zitadel/internal/admin/repository/eventsourcing/view"
|
2021-02-23 15:13:04 +01:00
|
|
|
"github.com/caos/zitadel/internal/eventstore/v1/spooler"
|
2020-05-26 16:46:16 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type SpoolerConfig struct {
|
|
|
|
BulkLimit uint64
|
|
|
|
FailureCountUntilSkip uint64
|
2020-07-28 09:42:21 +02:00
|
|
|
ConcurrentWorkers int
|
2020-05-26 16:46:16 +02:00
|
|
|
Handlers handler.Configs
|
|
|
|
}
|
|
|
|
|
2021-02-23 15:13:04 +01:00
|
|
|
func StartSpooler(c SpoolerConfig, es v1.Eventstore, view *view.View, sql *sql.DB, defaults systemdefaults.SystemDefaults) *spooler.Spooler {
|
2020-05-26 16:46:16 +02:00
|
|
|
spoolerConfig := spooler.Config{
|
2020-07-28 09:42:21 +02:00
|
|
|
Eventstore: es,
|
|
|
|
Locker: &locker{dbClient: sql},
|
|
|
|
ConcurrentWorkers: c.ConcurrentWorkers,
|
2021-02-22 14:08:47 +01:00
|
|
|
ViewHandlers: handler.Register(c.Handlers, c.BulkLimit, c.FailureCountUntilSkip, view, es, defaults),
|
2020-05-26 16:46:16 +02:00
|
|
|
}
|
|
|
|
spool := spoolerConfig.New()
|
|
|
|
spool.Start()
|
|
|
|
return spool
|
|
|
|
}
|