-
Notifications
You must be signed in to change notification settings - Fork 13
_Prtcl dev guide 9: Adding multiple backends
Inside Cortex, there is a builtin mechanism that allows for different service providers to interact with one another, the DiscoveryService. That service is in charge of fecthing any content-addressable object from any of our configured service providers by its hash.
But to make it work, alongside any service provider you need to include an instance of a KnownSourcesService to store where objects on other services provider live.
Let's add an instance of KnownSourcesHolochain and create a DiscoverableSource for our documentsProvider
of step 3.
import { KnownSourcesHolochain } from '@uprtcl/connections';
const knownSources = new KnownSourcesHolochain({
host: 'ws://localhost:8888',
instance: 'test-instance'
});
const discoverableDocs = {
service: documentsProvider,
knownSources: knownSources
};
To make it run, you need to run an instance of the discovery
zome in from the hc-uprtcl in your localhost.
If you want to known how the DiscoveryService
works, read on. Otherwise, you can just proceed to 10 - Adding lens selection.
The basic mechanic of the DiscoveryService
is as follows: in our application, we have configured different service providers that store content addressable objects. From one service provider, I can store content with links to objects in other service provider, as long as I know where to look for it in the form of a service provider identifier.
At any point in time, when we fetch content-addressable objects from a service provider, we ask its associated KnownSourcesService
for the location of the object's links to other content addressable objects. We store those "known sources" in an IndexDB table (by default), creating an index containing "where are the objects stored".
Later, when we want to update or create a content addressable object in a service provider, we get its links to other content addressable objects. Then, we add the known sources of those linked objects to the KnownSourcesService
associated to that service provider.
_Prtcl resources: Overview, Spec, Dev guide, API reference
4 - Configuring service providers
6 - Loading modules with micro-orchestrator
[TBD]10 - adding lens selection
[TBD] Using Cortex without modules
[TBD] Building a pattern
[TBD] Building a lens
[TBD] Building a service provider
[TBD] Building a Cortex module
[TBD] Customizing the lenses module
[TBD] Building a plugin for the lenses module