Support context propagation on overloads
Feature request checklist
- [x] There are no issues that match the desired change
- [ ] The change is large enough it can't be addressed with a simple Pull Request
- [ ] If this is a bug, please file a Bug Report.
Change
Currently, it is possible to use go contexts with the ContextEval(context.Context, interface{}) method. However, this context is not usable by function overloads.
Example
fn := &functions.ContextOverload{
Operator: "longRunningOperation",
Unary: func(ctx context.Context, value ref.Val) {
if err := longRunningOperation(ctx, value.Value()); err != nil {
return types.Bool(false)
}
return types.Bool(true)
}
}
This is similar to what's exposed in #368; however, in that PR the Context argument is not stored. Also, in Kubernetes it seems to be more common to store the callback channel.
There's been interest in reviving #368, so I'll take a look at what you're proposing and hopefully merge the approaches as best I can
@TristonianJones Is this still on the agenda? We might be a bit out of line doing async calls as part of custom CEL functions, but this would simplify those use cases quite a bit (partly in terms of propagating request deadline, but also caller authentication for upstream RPCs!).
@TristonianJones How can I help in adding this feature ?
For now, #368 seems to be frozen and being able to use the execution Context in overloads will be useful for network related functions