mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-15 04:18:01 +00:00
c0f55e7209
* fix: pub sub * fix: adaot config to commands (and queries) * remove dependency on vv2 in v1 * fix: pub sub in new eventstore * fix tests Co-authored-by: Livio Amstutz <livio.a@gmail.com>
28 lines
760 B
Go
28 lines
760 B
Go
package sdk
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/caos/zitadel/internal/errors"
|
|
es_models "github.com/caos/zitadel/internal/eventstore/v1/models"
|
|
)
|
|
|
|
type filterFunc func(context.Context, *es_models.SearchQuery) ([]*es_models.Event, error)
|
|
type appendFunc func(...*es_models.Event) error
|
|
type AggregateFunc func(context.Context) (*es_models.Aggregate, error)
|
|
|
|
func Filter(ctx context.Context, filter filterFunc, appender appendFunc, query *es_models.SearchQuery) error {
|
|
events, err := filter(ctx, query)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if len(events) == 0 {
|
|
return errors.ThrowNotFound(nil, "EVENT-8due3", "no events found")
|
|
}
|
|
err = appender(events...)
|
|
if err != nil {
|
|
return ThrowAppendEventError(err, "SDK-awiWK", "Errors.Internal")
|
|
}
|
|
return nil
|
|
}
|