diff --git a/routing/query.go b/routing/query.go index 42acdb1fbb5644cdec443e99c748c8970bd36630..26743af09d32122b93c9838fdba48f99affe21e8 100644 --- a/routing/query.go +++ b/routing/query.go @@ -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 +}