-
Notifications
You must be signed in to change notification settings - Fork 247
Provider interface #1093
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
base: reprovide-sweep
Are you sure you want to change the base?
Provider interface #1093
Conversation
## Suggested `SweepingReprovider` interface | ||
|
||
```go | ||
type Provider interface { |
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.
This interface is currently named Reprovider
, in go-libp2p-kad-dht/reprovider
.
I figured the name Provider
makes more sense since its users only need to know that this is a content routing provider. They don't need to know the internals of whether the content has to be reprovided. The goal is to signal that the Provider
takes the responsibility to advertise content as needed to the remote content routing system (DHT here).
I initially chose Reprovider
because go-libp2p-kad-dht/providers/
already exists, and because kubo Provider is the old boxo providing system. I now think it makes more sense to use Provider
.
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.
I think that a Provider
interface makes most sense.
reprovider/interface.md
Outdated
|
||
// ForceProvide is similar to StartProviding, but it sends provider records out | ||
// to the DHT even if the keys were already provided in the past. | ||
ForceProvide(context.Context, ...mh.Multihash) error |
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.
nit: name tbd, but should reflect this is ing
version that needs to be stopped
ForceProvide(context.Context, ...mh.Multihash) error | |
StartProvidingAndForceInstantProvide(context.Context, ...mh.Multihash) error |
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.
ForceStartProviding
?
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.
I wrote this a few day ago. Mostly comments about namings. Along same lines of more recent comments.
reprovider/interface.md
Outdated
|
||
// ForceProvide is similar to StartProviding, but it sends provider records out | ||
// to the DHT even if the keys were already provided in the past. | ||
ForceProvide(context.Context, ...mh.Multihash) error |
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.
Not saying it must, but perhaps can be merged into StartProviding(ctx, now bool, mh.Multihash)
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.
Alternative names ProvideNow
or just Provide
.
Very explicit: ImmediateSingleProvide()
.
This PR is just a place to discuss the interface, it doesn't contain actual code.
DHT Provider Interface
Here is the suggested Provider interface for the
SweepingReprovider
, to be used in kubo to replaceboxo/provider
System
/Provider
interface.Note that the interface would also be implemented by a dual DHT Sweeping Provider.
We can extend the interface as needed (e.g
Stats()
).Kubo integration
If we want both Provide systems (
go-libp2p-kad-dht:Provider
andboxo:Provider
) to be swappable in kubo (at least for a transition period), it would be convenient to have a common interface for both systems.IMO it is easier to wrap
boxo:Provider
aroundgo-libp2p-kad-dht:Provider
than the other way around, sincego-libp2p-kad-dht:Provider
is "richer".However,
go-libp2p-kad-dht:Provider
doesn't have a concept ofReprovide
to trigger a general reprovide of all keys, which is required byboxo:Provider
. AFAIK only theipfs routing reprovide
command is usingboxo:Provider.Reprovide
, so it should be easy enough to cast and if the provide system in use in kubo isboxo:Provider
, the reprovide command happens as it used to, otherwise mark it as deprecated with the new provide system.If
boxo:Provider
is wrapped in thego-libp2p-kad-dht:Provider
interface,StartProviding()
,InstantProvide()
andForceProvide()
could be mapped toboxo:Provider.Provide()
, andStopProviding()
would be a noop.@lidel @hsanjuan @gammazero WDYT? We can still change the interface easily at this point.