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"
|
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-03-14 07:55:09 +01:00
|
|
|
func Start(conf Config,
|
|
|
|
dir http.FileSystem,
|
2022-04-25 11:16:36 +02:00
|
|
|
externalPort uint16,
|
|
|
|
externalSecure bool,
|
2022-03-14 07:55:09 +01:00
|
|
|
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 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-04-25 11:16:36 +02:00
|
|
|
spool := spooler.StartSpooler(conf.Spooler, es, view, dbClient, command, queries, externalPort, externalSecure, dir, assetsPrefix, userEncryption, smtpEncryption, smsEncryption)
|
2020-05-20 14:28:08 +02:00
|
|
|
|
|
|
|
return &EsRepository{
|
|
|
|
spool,
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (repo *EsRepository) Health() error {
|
|
|
|
return nil
|
|
|
|
}
|