mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-15 04:18:01 +00:00
8dcbbc87ca
* fix: adaot config to commands (and queries) * remove dependency on vv2 in v1 * add queries user to operator * set password for queries on tests * set password for queries on tests * fix config
40 lines
1.2 KiB
Go
40 lines
1.2 KiB
Go
package v1
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/caos/zitadel/internal/eventstore/v1/internal/repository"
|
|
"github.com/caos/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)
|
|
LatestSequence(ctx context.Context, searchQuery *models.SearchQueryFactory) (uint64, error)
|
|
Subscribe(aggregates ...models.AggregateType) *Subscription
|
|
}
|
|
|
|
var _ Eventstore = (*eventstore)(nil)
|
|
|
|
type eventstore struct {
|
|
repo repository.Repository
|
|
}
|
|
|
|
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) LatestSequence(ctx context.Context, queryFactory *models.SearchQueryFactory) (uint64, error) {
|
|
sequenceFactory := *queryFactory
|
|
sequenceFactory = *(&sequenceFactory).Columns(models.Columns_Max_Sequence)
|
|
sequenceFactory = *(&sequenceFactory).SequenceGreater(0)
|
|
return es.repo.LatestSequence(ctx, &sequenceFactory)
|
|
}
|
|
|
|
func (es *eventstore) Health(ctx context.Context) error {
|
|
return es.repo.Health(ctx)
|
|
}
|