2020-05-20 12:28:08 +00:00
|
|
|
package spooler
|
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql"
|
2021-07-13 05:13:39 +00:00
|
|
|
"net/http"
|
|
|
|
|
2021-02-23 14:13:04 +00:00
|
|
|
"github.com/caos/zitadel/internal/command"
|
|
|
|
"github.com/caos/zitadel/internal/eventstore/v1"
|
2021-12-16 14:21:37 +00:00
|
|
|
"github.com/caos/zitadel/internal/query"
|
2020-07-28 07:42:21 +00:00
|
|
|
|
2020-05-20 12:28:08 +00:00
|
|
|
sd "github.com/caos/zitadel/internal/config/systemdefaults"
|
2021-02-23 14:13:04 +00:00
|
|
|
"github.com/caos/zitadel/internal/eventstore/v1/spooler"
|
2020-05-20 12:28:08 +00:00
|
|
|
"github.com/caos/zitadel/internal/notification/repository/eventsourcing/handler"
|
|
|
|
"github.com/caos/zitadel/internal/notification/repository/eventsourcing/view"
|
|
|
|
)
|
|
|
|
|
|
|
|
type SpoolerConfig struct {
|
|
|
|
BulkLimit uint64
|
|
|
|
FailureCountUntilSkip uint64
|
2020-07-28 07:42:21 +00:00
|
|
|
ConcurrentWorkers int
|
2020-05-20 12:28:08 +00:00
|
|
|
Handlers handler.Configs
|
|
|
|
}
|
|
|
|
|
2021-12-16 14:21:37 +00:00
|
|
|
func StartSpooler(c SpoolerConfig, es v1.Eventstore, view *view.View, sql *sql.DB, command *command.Commands, queries *query.Queries, systemDefaults sd.SystemDefaults, dir http.FileSystem, apiDomain string) *spooler.Spooler {
|
2020-05-20 12:28:08 +00:00
|
|
|
spoolerConfig := spooler.Config{
|
2020-07-28 07:42:21 +00:00
|
|
|
Eventstore: es,
|
|
|
|
Locker: &locker{dbClient: sql},
|
|
|
|
ConcurrentWorkers: c.ConcurrentWorkers,
|
2021-12-16 14:21:37 +00:00
|
|
|
ViewHandlers: handler.Register(c.Handlers, c.BulkLimit, c.FailureCountUntilSkip, view, es, command, queries, systemDefaults, dir, apiDomain),
|
2020-05-20 12:28:08 +00:00
|
|
|
}
|
|
|
|
spool := spoolerConfig.New()
|
|
|
|
spool.Start()
|
|
|
|
return spool
|
|
|
|
}
|