Skip to content
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

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

aschmahmann
Copy link
Contributor

fixes #640

This is an attempt at splitting the ProviderQueryManager out of Bitswap so that we can configure it more in consumers.

@aschmahmann aschmahmann force-pushed the feat/configurable-providequerymanager branch from a6677c4 to f538d1f Compare July 26, 2024 11:06
Copy link

codecov bot commented Jul 26, 2024

Codecov Report

Attention: Patch coverage is 48.11321% with 55 lines in your changes missing coverage. Please review.

Project coverage is 59.77%. Comparing base (2816b71) to head (e95eeb2).
Report is 67 commits behind head on main.

Files with missing lines Patch % Lines
bitswap/client/internal/session/session.go 0.00% 26 Missing ⚠️
...uting/providerquerymanager/providerquerymanager.go 55.88% 14 Missing and 1 partial ⚠️
bitswap/client/client.go 75.60% 9 Missing and 1 partial ⚠️
bitswap/options.go 0.00% 4 Missing ⚠️

Impacted file tree graph

@@            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     
Files with missing lines Coverage Δ
routing/mock/centralized_client.go 57.50% <100.00%> (-5.00%) ⬇️
bitswap/options.go 34.78% <0.00%> (-3.32%) ⬇️
bitswap/client/client.go 86.90% <75.60%> (-3.13%) ⬇️
...uting/providerquerymanager/providerquerymanager.go 86.11% <55.88%> (ø)
bitswap/client/internal/session/session.go 82.86% <0.00%> (-8.68%) ⬇️

... and 12 files with indirect coverage changes

@aschmahmann aschmahmann force-pushed the feat/configurable-providequerymanager branch from f538d1f to e95eeb2 Compare July 26, 2024 11:11
Comment on lines 81 to +86
FindProvidersAsync(ctx context.Context, k cid.Cid) <-chan peer.ID
}

type FindAllProviders struct {
Router bsnet.BitSwapNetwork
}
Copy link
Contributor Author

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.

Comment on lines +91 to +116
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
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove requirement on ProviderQueryManager from the bitswap client
1 participant