-
Notifications
You must be signed in to change notification settings - Fork 0
KV interface for stored Evaluables in aggregate engines #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This allows evals to be stored on disk via eg. a Pebble KV store.
| type ExpressionEvaluator func(ctx context.Context, e Evaluable, input map[string]any) (bool, error) | ||
|
|
||
| // EvaluableLoader returns one or more evaluable items given IDs. | ||
| type EvaluableLoader func(ctx context.Context, evaluableIDs ...uuid.UUID) ([]Evaluable, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cleanup - this is unused.
| // | ||
| // An AggregateEvaluator instance exists for every event name being matched. | ||
| type AggregateEvaluator interface { | ||
| type AggregateEvaluator[T Evaluable] interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the sake of the review, we must store a concrete type in the aggregator for marshalling to and from the concrete type in the KV storage. This requires generics.
| // Attempt to unmarshal an empty byte slice, ensuring that we have | ||
| // a concrete type instead of an interface. | ||
| if _, err := kvopts.Unmarshal([]byte("{}")); err != nil { | ||
| panic(fmt.Sprintf("unable to make KV for aggregate evaluator without concrete type: %s", err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this allows us to fail fast in unit tests, but will never hit in our services — KVOpts will always pass in a KV constructor.
This implements a KV storage interface for the aggregate expression engine. This lets us provide a new PebbleDB instance into aggregate engines, meaning that pauses will be written to disk instead of stored in memory.