hyperledger / cacti

Hyperledger Cacti is a new approach to the blockchain interoperability problem
https://wiki.hyperledger.org/display/cactus
Apache License 2.0
339 stars 277 forks source link

feat(core-api): per plugin instance routing via SDK #225

Open petermetz opened 4 years ago

petermetz commented 4 years ago

Description

As a consortium member I want to be able address individual plugin instances through the main consortium DNS Host so that if different instances of plugins have meaningfully different configurations (connected to separate ledgers for example) then I can address these ledgers specifically via their associated plugin instances. Other examples are out there, but the one that was brought to my attention was the different ledger connector plugins.

Example

  1. Two separate servers are running the Cactus API Server
  2. They both have the besu ledger plugin deployed, but for two different besu ledgers LedgerA and LedgerB
  3. The main consortium DNS host is https://www.cactus.stream
  4. One member host is https://www.member-b.cactus.stream and the other is https://www.member-a.cactus.stream
  5. A client mobile or web application has the cactus-api-client package installed and is looking to work with both LedgerA and LedgerB and would like to avoid writing logic in their application code that deals with different DNS hosts (the member subdomains).
  6. The client application author does not want to hand-craft request URLs because they want the convenience of the type checking provided the cactus-api-client package (Typescript compiler).

Acceptance Criteria

  1. Solution is fully type-checked so that the SDK is 100% usable regardless of users opting to have this type of dynamic routing or not
  2. Individual plugin instances are addressable through the SDK

cc: @jonathan-m-hamilton @takeutak @sfuji822

sfuji822 commented 4 years ago

I could not understand the use case which you described. The integrated service which is powered by HL-Cactus, should not be configured by user-side, but it may be (re)conrefigured by administrator of the service provider(s). I thought that any client applications will not involve instantiation of plugin (server?) as you described above. Can you provide further description regarding instantiation of plugin server ?

petermetz commented 4 years ago

I could not understand the use case which you described. The integrated service which is powered by HL-Cactus, should not be configured by user-side, but it may be (re)conrefigured by administrator of the service provider(s).

Apologies @sfuji822 by user in that sentence I meant developer who uses Cactus to create a business application. I'll fix it right now to say it like that so it's not misleading.

Can you provide further description regarding instantiation of plugin server ?

Yes! Now that I have the PR open in the meantime, I can do the best thing, link to the actual code file where it gets instantiated in this test file:

packages/cactus-test-plugin-consortium-manual/src/test/typescript/integration/plugin-consortium-manual/get-consortium-jws-endpoint.test.ts that you can observe at the link below: https://github.com/hyperledger/cactus/pull/242/files#diff-ab0638c8023a5c255e1f69700638157c

I recommend reading the whole file at least on a high level, but the instantiation is on this line to be exact: https://github.com/hyperledger/cactus/pull/242/files#diff-ab0638c8023a5c255e1f69700638157cR135

I thought that any client applications will not involve instantiation of plugin (server?) as you described above. They don't necessarily have to no. In the test case above I just instantiate everything together because it's a test case where I need to set up everything from scratch, but that doesn't mean that you cannot use the SDK in a separate application that runs in the browser for example. Case in point is the new page I also added as part of the PR to the cactus-cockpit package where you can see the SDK being used to query the consortium JWS':

packages/cactus-cockpit/src/app/consortium-inspector/consortium-inspector.page.ts

https://github.com/hyperledger/cactus/pull/242/files#diff-653e5873bc9ceb1c10d63474badaed07R48