2020-05-13 14:22:29 +02:00
|
|
|
package eventsourcing
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2021-06-11 13:20:39 +02:00
|
|
|
|
2022-04-27 01:01:45 +02:00
|
|
|
"github.com/zitadel/zitadel/internal/admin/repository/eventsourcing/eventstore"
|
|
|
|
"github.com/zitadel/zitadel/internal/admin/repository/eventsourcing/spooler"
|
|
|
|
admin_view "github.com/zitadel/zitadel/internal/admin/repository/eventsourcing/view"
|
2023-02-27 22:36:43 +01:00
|
|
|
"github.com/zitadel/zitadel/internal/database"
|
2022-11-22 07:36:48 +01:00
|
|
|
eventstore2 "github.com/zitadel/zitadel/internal/eventstore"
|
2022-04-27 01:01:45 +02:00
|
|
|
v1 "github.com/zitadel/zitadel/internal/eventstore/v1"
|
|
|
|
es_spol "github.com/zitadel/zitadel/internal/eventstore/v1/spooler"
|
|
|
|
"github.com/zitadel/zitadel/internal/static"
|
2020-05-13 14:22:29 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type Config struct {
|
2020-05-26 16:46:16 +02:00
|
|
|
SearchLimit uint64
|
|
|
|
Spooler spooler.SpoolerConfig
|
2020-05-13 14:22:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type EsRepository struct {
|
2020-05-26 16:46:16 +02:00
|
|
|
spooler *es_spol.Spooler
|
2020-06-25 08:01:13 +02:00
|
|
|
eventstore.AdministratorRepo
|
2020-05-13 14:22:29 +02:00
|
|
|
}
|
|
|
|
|
2023-02-27 22:36:43 +01:00
|
|
|
func Start(ctx context.Context, conf Config, static static.Storage, dbClient *database.DB, esV2 *eventstore2.Eventstore) (*EsRepository, error) {
|
2022-02-14 17:22:30 +01:00
|
|
|
es, err := v1.Start(dbClient)
|
2020-05-13 14:22:29 +02:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2022-02-14 17:22:30 +01:00
|
|
|
view, err := admin_view.StartView(dbClient)
|
2020-05-26 16:46:16 +02:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2022-11-22 07:36:48 +01:00
|
|
|
spool := spooler.StartSpooler(ctx, conf.Spooler, es, esV2, view, dbClient, static)
|
2021-07-13 07:13:39 +02:00
|
|
|
|
2020-05-13 14:22:29 +02:00
|
|
|
return &EsRepository{
|
2020-05-26 16:46:16 +02:00
|
|
|
spooler: spool,
|
2020-06-25 08:01:13 +02:00
|
|
|
AdministratorRepo: eventstore.AdministratorRepo{
|
|
|
|
View: view,
|
|
|
|
},
|
2020-05-13 14:22:29 +02:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (repo *EsRepository) Health(ctx context.Context) error {
|
2021-02-22 14:08:47 +01:00
|
|
|
return nil
|
2020-05-13 14:22:29 +02:00
|
|
|
}
|