mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-14 20:08:02 +00:00
aed7010508
* fix: improve scheduling * build pre-release * fix: locker * fix: user handler and print stack in case of panic in reducer * chore: remove sentry * fix: improve handler projection and implement tests * more tests * fix: race condition in tests * Update internal/eventstore/repository/sql/query.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * fix: implemented suggested changes * fix: lock statement Co-authored-by: Silvan <silvan.reusser@gmail.com>
48 lines
1.4 KiB
Go
48 lines
1.4 KiB
Go
package v1
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
|
|
"github.com/zitadel/zitadel/internal/eventstore/v1/internal/repository"
|
|
z_sql "github.com/zitadel/zitadel/internal/eventstore/v1/internal/repository/sql"
|
|
"github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
|
)
|
|
|
|
type Eventstore interface {
|
|
Health(ctx context.Context) error
|
|
FilterEvents(ctx context.Context, searchQuery *models.SearchQuery) (events []*models.Event, err error)
|
|
Subscribe(aggregates ...models.AggregateType) *Subscription
|
|
InstanceIDs(ctx context.Context, searchQuery *models.SearchQuery) ([]string, error)
|
|
}
|
|
|
|
var _ Eventstore = (*eventstore)(nil)
|
|
|
|
type eventstore struct {
|
|
repo repository.Repository
|
|
}
|
|
|
|
func Start(db *sql.DB) (Eventstore, error) {
|
|
return &eventstore{
|
|
repo: z_sql.Start(db),
|
|
}, nil
|
|
}
|
|
|
|
func (es *eventstore) FilterEvents(ctx context.Context, searchQuery *models.SearchQuery) ([]*models.Event, error) {
|
|
if err := searchQuery.Validate(); err != nil {
|
|
return nil, err
|
|
}
|
|
return es.repo.Filter(ctx, models.FactoryFromSearchQuery(searchQuery))
|
|
}
|
|
|
|
func (es *eventstore) Health(ctx context.Context) error {
|
|
return es.repo.Health(ctx)
|
|
}
|
|
|
|
func (es *eventstore) InstanceIDs(ctx context.Context, searchQuery *models.SearchQuery) ([]string, error) {
|
|
if err := searchQuery.Validate(); err != nil {
|
|
return nil, err
|
|
}
|
|
return es.repo.InstanceIDs(ctx, models.FactoryFromSearchQuery(searchQuery))
|
|
}
|