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

feat: Sequential and Parallel Routers #58

Merged
merged 15 commits into from
Sep 16, 2022

Conversation

ajnavarro
Copy link
Member

@ajnavarro ajnavarro commented Aug 26, 2022

It closes #56

composable/sequential.go Outdated Show resolved Hide resolved
compparallel.go Outdated Show resolved Hide resolved
compparallel.go Outdated Show resolved Hide resolved
compparallel.go Outdated Show resolved Hide resolved
compparallel.go Outdated Show resolved Hide resolved
compparallel.go Outdated Show resolved Hide resolved
compparallel.go Outdated Show resolved Hide resolved
compparallel.go Outdated Show resolved Hide resolved
compsequential.go Outdated Show resolved Hide resolved
Comment on lines 61 to 62
case <-ctx.Done():
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the context is cancelled this cancels the current router but then it continues w/ the rest of the routers, we probably ought to short-circuit the whole loop at this point to avoid kicking off a bunch of wasteful queries.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, that's tricky, because that context is the specific router context with the timeout, so maybe the next routers still have execution time.

compparallel.go Outdated Show resolved Hide resolved
@ajnavarro ajnavarro force-pushed the feature/paralel-sequential-routers branch from d799146 to f38160d Compare September 6, 2022 08:22
@ajnavarro ajnavarro marked this pull request as ready for review September 6, 2022 14:57
@ajnavarro ajnavarro changed the title Sequential and Parallel Routers feat: Sequential and Parallel Routers Sep 6, 2022
compparallel.go Outdated Show resolved Hide resolved
compparallel.go Show resolved Hide resolved
compparallel.go Outdated Show resolved Hide resolved
compparallel.go Outdated Show resolved Hide resolved
compparallel.go Outdated Show resolved Hide resolved
Comment on lines +24 to +27
type ProvideManyRouter interface {
ProvideMany(ctx context.Context, keys []multihash.Multihash) error
Ready() bool
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This interface is duplicated in multiple places and is ultimately what we need to consume a router in Kubo, right? Is there a way to move this somewhere authoritative? Should this be in libp2p? Also does this need to be exported?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be where routing.Routing interface is living. It is public to at least have one source of truth that can be used anywhere.

compparallel.go Outdated Show resolved Hide resolved
compparallel.go Outdated Show resolved Hide resolved
compsequential.go Outdated Show resolved Hide resolved
compsequential.go Outdated Show resolved Hide resolved
@ajnavarro ajnavarro force-pushed the feature/paralel-sequential-routers branch from 8fd91c4 to 0c84fe9 Compare September 15, 2022 16:37
Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
!errors.Is(err, routing.ErrNotFound) &&
!router.IgnoreError {
cancel()
break
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it makes sense to log these attempts and errors at info/debug level so that someone can debug what's happening? (if so, we can follow up with this in a separate PR)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, it would make sense

compsequential.go Outdated Show resolved Hide resolved
Copy link
Contributor

@guseggert guseggert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I guess there two followups here:

  • Add some logging so we can debug what's happening (errors, control flow, etc.)
  • Look into moving ProvideManyRouter into the libp2p routing package

@ajnavarro
Copy link
Member Author

@guseggert

@ajnavarro ajnavarro merged commit cd3e478 into master Sep 16, 2022
@ajnavarro ajnavarro deleted the feature/paralel-sequential-routers branch September 16, 2022 18:22
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.

New Routing helpers: parallel and sequential.
2 participants