2020-05-20 14:28:08 +02:00
|
|
|
package eventsourcing
|
|
|
|
|
|
|
|
import (
|
2022-02-14 17:22:30 +01:00
|
|
|
"database/sql"
|
2021-07-13 07:13:39 +02:00
|
|
|
"net/http"
|
|
|
|
|
2021-02-23 15:13:04 +01:00
|
|
|
"github.com/caos/zitadel/internal/command"
|
2020-05-20 14:28:08 +02:00
|
|
|
sd "github.com/caos/zitadel/internal/config/systemdefaults"
|
2022-02-16 16:49:17 +01:00
|
|
|
"github.com/caos/zitadel/internal/crypto"
|
2022-02-14 17:22:30 +01:00
|
|
|
v1 "github.com/caos/zitadel/internal/eventstore/v1"
|
2021-02-23 15:13:04 +01:00
|
|
|
es_spol "github.com/caos/zitadel/internal/eventstore/v1/spooler"
|
2020-05-20 14:28:08 +02:00
|
|
|
"github.com/caos/zitadel/internal/notification/repository/eventsourcing/spooler"
|
|
|
|
noti_view "github.com/caos/zitadel/internal/notification/repository/eventsourcing/view"
|
2022-02-14 17:22:30 +01:00
|
|
|
"github.com/caos/zitadel/internal/query"
|
2020-05-20 14:28:08 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type Config struct {
|
2022-02-14 17:22:30 +01:00
|
|
|
Spooler spooler.SpoolerConfig
|
2020-05-20 14:28:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type EsRepository struct {
|
|
|
|
spooler *es_spol.Spooler
|
|
|
|
}
|
|
|
|
|
2022-02-16 16:49:17 +01:00
|
|
|
func Start(conf Config, dir http.FileSystem, systemDefaults sd.SystemDefaults, command *command.Commands, queries *query.Queries, dbClient *sql.DB, assetsPrefix string, smtpPasswordEncAlg crypto.EncryptionAlgorithm) (*EsRepository, error) {
|
2022-02-14 17:22:30 +01:00
|
|
|
es, err := v1.Start(dbClient)
|
2020-05-20 14:28:08 +02:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2022-02-14 17:22:30 +01:00
|
|
|
view, err := noti_view.StartView(dbClient)
|
2020-05-20 14:28:08 +02:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2022-02-16 16:49:17 +01:00
|
|
|
spool := spooler.StartSpooler(conf.Spooler, es, view, dbClient, command, queries, systemDefaults, dir, assetsPrefix, smtpPasswordEncAlg)
|
2020-05-20 14:28:08 +02:00
|
|
|
|
|
|
|
return &EsRepository{
|
|
|
|
spool,
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (repo *EsRepository) Health() error {
|
|
|
|
return nil
|
|
|
|
}
|