Unverified Commit a4b837bc authored by Steven Allen's avatar Steven Allen Committed by GitHub

Merge pull request #147 from libp2p/feat/subscribes-to-events

feat: add a function to tell if a context subscribes to query events
parents a14197ce 5d9ec028
......@@ -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