Commit 5d9ec028 authored by Steven Allen's avatar Steven Allen

feat: add a function to tell if a context subscribes to query events

This can save us some work if the caller doesn't actually care about these events.
parent a14197ce
......@@ -102,3 +102,10 @@ func PublishQueryEvent(ctx context.Context, ev *QueryEvent) {
ech := ich.(*eventChannel)
ech.send(ctx, ev)
}
// SubscribesToQueryEvents returns true if the context subscribes to query
// events. If this function returns falls, calling `PublishQueryEvent` on the
// context will be a no-op.
func SubscribesToQueryEvents(ctx context.Context) bool {
return ctx.Value(routingQueryKey{}) != nil
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment