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