-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
configurable providerquerymanager #641
base: main
Are you sure you want to change the base?
Conversation
a6677c4
to
f538d1f
Compare
Codecov ReportAttention: Patch coverage is
@@ Coverage Diff @@
## main #641 +/- ##
==========================================
- Coverage 59.82% 59.77% -0.06%
==========================================
Files 238 238
Lines 29976 30045 +69
==========================================
+ Hits 17933 17958 +25
- Misses 10424 10470 +46
+ Partials 1619 1617 -2
|
…le to turn off the ProviderQueryManager
…add options, add WithMaxTimeout option
…rocessRequests option
f538d1f
to
e95eeb2
Compare
FindProvidersAsync(ctx context.Context, k cid.Cid) <-chan peer.ID | ||
} | ||
|
||
type FindAllProviders struct { | ||
Router bsnet.BitSwapNetwork | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're going to keep the function here as not taking a count
the name should get changed from FindProvidersAsync
to one that doesn't collide with the more widely used function that does take a count so implementations can use both if they want.
provCh := make(chan peer.ID) | ||
wg := &sync.WaitGroup{} | ||
for p := range providers { | ||
wg.Add(1) | ||
go func(p peer.ID) { | ||
defer wg.Done() | ||
span.AddEvent("FoundProvider", trace.WithAttributes(attribute.Stringer("peer", p))) | ||
err := r.Router.ConnectTo(ctx, p) | ||
if err != nil { | ||
span.RecordError(err, trace.WithAttributes(attribute.Stringer("peer", p))) | ||
log.Debugf("failed to connect to provider %s: %s", p, err) | ||
return | ||
} | ||
span.AddEvent("ConnectedToProvider", trace.WithAttributes(attribute.Stringer("peer", p))) | ||
select { | ||
case provCh <- p: | ||
case <-ctx.Done(): | ||
return | ||
} | ||
}(p) | ||
} | ||
go func() { | ||
wg.Wait() | ||
close(provCh) | ||
}() | ||
return provCh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this was copied out of the ProviderQueryManager because the internals (or at least the tests) seem to rely on having the connections made explicit here. It seems reasonable to extract this up a level out of the routing component though.
@aschmahmann Does this mean we still want the provider query manager, and need to close #536 which removes it. |
fixes #640
This is an attempt at splitting the ProviderQueryManager out of Bitswap so that we can configure it more in consumers.