Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

Commit

Permalink
Merge pull request #147 from libp2p/feat/subscribes-to-events
Browse files Browse the repository at this point in the history
feat: add a function to tell if a context subscribes to query events
  • Loading branch information
Stebalien authored Apr 29, 2020
2 parents a14197c + 5d9ec02 commit a4b837b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions routing/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit a4b837b

Please sign in to comment.