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