2020-05-20 14:28:08 +02:00
|
|
|
package eventsourcing
|
|
|
|
|
|
|
|
import (
|
2021-02-23 15:13:04 +01:00
|
|
|
"github.com/caos/zitadel/internal/command"
|
|
|
|
"github.com/caos/zitadel/internal/eventstore/v1"
|
2020-07-08 09:48:11 +02:00
|
|
|
"net/http"
|
|
|
|
|
2020-05-20 14:28:08 +02:00
|
|
|
sd "github.com/caos/zitadel/internal/config/systemdefaults"
|
|
|
|
"github.com/caos/zitadel/internal/config/types"
|
2021-02-23 15:13:04 +01:00
|
|
|
es_spol "github.com/caos/zitadel/internal/eventstore/v1/spooler"
|
2020-06-09 15:11:42 +02:00
|
|
|
"github.com/caos/zitadel/internal/i18n"
|
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"
|
2020-06-09 15:11:42 +02:00
|
|
|
"golang.org/x/text/language"
|
2020-05-20 14:28:08 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type Config struct {
|
2020-06-09 15:11:42 +02:00
|
|
|
DefaultLanguage language.Tag
|
2021-02-23 15:13:04 +01:00
|
|
|
Eventstore v1.Config
|
2020-06-09 15:11:42 +02:00
|
|
|
View types.SQL
|
|
|
|
Spooler spooler.SpoolerConfig
|
2020-07-07 19:31:51 +02:00
|
|
|
Domain string
|
2020-05-20 14:28:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type EsRepository struct {
|
|
|
|
spooler *es_spol.Spooler
|
|
|
|
}
|
|
|
|
|
2021-02-24 11:17:39 +01:00
|
|
|
func Start(conf Config, dir http.FileSystem, systemDefaults sd.SystemDefaults, command *command.Commands) (*EsRepository, error) {
|
2021-02-23 15:13:04 +01:00
|
|
|
es, err := v1.Start(conf.Eventstore)
|
2020-05-20 14:28:08 +02:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
sqlClient, err := conf.View.Start()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
view, err := noti_view.StartView(sqlClient)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-07-08 09:48:11 +02:00
|
|
|
translator, err := i18n.NewTranslator(dir, i18n.TranslatorConfig{DefaultLanguage: conf.DefaultLanguage})
|
2020-06-09 15:11:42 +02:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2021-02-22 14:08:47 +01:00
|
|
|
spool := spooler.StartSpooler(conf.Spooler, es, view, sqlClient, command, systemDefaults, translator, dir)
|
2020-05-20 14:28:08 +02:00
|
|
|
|
|
|
|
return &EsRepository{
|
|
|
|
spool,
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (repo *EsRepository) Health() error {
|
|
|
|
return nil
|
|
|
|
}
|