-
Notifications
You must be signed in to change notification settings - Fork 72
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(daemon): Add reverseLocate()
and followLocatorNameChanges()
#2195
Conversation
aec68a5
to
13bbec1
Compare
1929957
to
cb91afe
Compare
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.
So far, so good!
13bbec1
to
89524a3
Compare
cb91afe
to
62a2efe
Compare
b3b7c9c
to
9784695
Compare
reverseLocate()
and followLocatorNames()
reverseLocate()
and followLocatorNameChanges()
aa8be0b
to
2b6fd73
Compare
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.
Worth considering whether we might just factor a light-client out of followLocatorNameChanges
that is based on a sharable subscription to followNameChanges
. That might put the tracking burden closer to where it ought to be and relax the need to perform timely identifier GC.
@@ -97,6 +97,30 @@ export const makeDirectoryMaker = ({ | |||
return formatLocator(id, formulaType); | |||
}; | |||
|
|||
/** @type {import('./types.js').EndoDirectory['reverseLocate']} */ | |||
const reverseLocate = async locator => { |
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.
Silly idea:
- “locate” means “get locator for name”
- “nominate” means “get name from locator”
Adds reverseLocate() to the directory. Also refactors locator utilities for better coherence with their formula identifier equivalents. Adds idFromLocator().
Adds an initial implementation of `followLocatorNameChanges()`, which publishes the extant names for a specific id, if any. Tests are added for the same.
Ensures that overwriting names during pet store renames publishes a removal event. The removal event(s) will always be published first. The behavior is tested both for overwrites and non-overwrites.
Replaces all references to "diff" in pubsub type names to "name change" to match the names of the pubsub APIs (e.g. `followNameChanges`). Also removes an extraneous `if` condition.
2b6fd73
to
37bb657
Compare
Adds
reverseLocate()
andfollowLocatorNameChanges()
to the daemon's directory. To match this new method, the directory'sfollowChanges()
and the pet store's underlyingfollow()
are renamed tofollowNameChanges()
.The directory's
reverseLocate(locator)
andfollowLocatorNameChanges(locator)
are backed up by the pet store'sreverseIdentify(id)
andfollowIdNameChanges(id)
, respectively. The implementation of the former is very straightforward. The implementation of the latter required the introduction of a new pubsub topic,idChangesTopic
, and a map from ids toidChangesTopic
subscriptions (one for each id).Since the pet store is unaware of whether ids exist,
followIdNameChanges()
will naively create a subscription that first publishes an empty array of names, and then any subsequent names that are added for that id.followLocatorNameChanges()
inherits this property.The current implementation suffers from the limitation that locator name change subscriptions cannot be ended. A follow-up will introduce the ability for subscribers to cancel their subscription. Locator subscriptions will also be a target for our future garbage collector, which will delete subscriptions for unreachable locators. Cancelling a locator should not end the subscription, because we consider the liveness of a value to be orthogonal to the subscriber's interest in changes to its names.