endojs / endo

Endo is a distributed secure JavaScript sandbox, based on SES
Apache License 2.0
768 stars 68 forks source link

feat(daemon): Add `reverseLocate()` and `followLocatorNameChanges()` #2195

Closed rekmarks closed 2 months ago

rekmarks commented 3 months ago

Adds reverseLocate() and followLocatorNameChanges() to the daemon's directory. To match this new method, the directory's followChanges() and the pet store's underlying follow() are renamed to followNameChanges().

The directory's reverseLocate(locator) and followLocatorNameChanges(locator) are backed up by the pet store's reverseIdentify(id) and followIdNameChanges(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 to idChangesTopic 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.