-
Notifications
You must be signed in to change notification settings - Fork 286
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: out of process plugin instances for language independence #475
Merged
petermetz
merged 3 commits into
hyperledger-cacti:main
from
petermetz:feat/out-of-process-plugin-instances-for-language-independence-170
Jan 14, 2021
Merged
feat: out of process plugin instances for language independence #475
petermetz
merged 3 commits into
hyperledger-cacti:main
from
petermetz:feat/out-of-process-plugin-instances-for-language-independence-170
Jan 14, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
petermetz
added
enhancement
New feature or request
SPIKE
Exploratory work to better scope additional effort
API_Server
dependencies
Pull requests that update a dependency file
Security
Related to existing or potential security vulnerabilities
Developer_Experience
Significant_Change
Applying this label triggers the more stringent review of the maintainers and the 2+1 PR rule.
labels
Jan 13, 2021
jonathan-m-hamilton
approved these changes
Jan 13, 2021
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.
LGTM
takeutak
approved these changes
Jan 14, 2021
List of files with the interesting changes ================================= The rest of the diff is mostly just compiler worship. ./packages/cactus-core-api/src/main/typescript/openapi-spec.ts ./packages/cactus-core-api/src/main/typescript/plugin-factory-factory.ts ./packages/cactus-core-api/src/main/typescript/i-plugin-factory-options.ts ./packages/cactus-cmd-api-server/src/main/typescript/api-server.ts Primary change ============= The original plugin import type that the API server received via configuration (via ENV, CLI or FILE). The `type` property of the plugin import can be used by the different `createPluginFactory()` implementations to determine the kind of factory they need to return. For example: 1. For `LOCAL` type of plugin imports, the factory returned will construct the actual plugin implementation class (e.g. directly instantiate it) 2. For `REMOTE` type of plugin imports, the factory returned will create an API client object, configured to point to an arbitrary implementation of the plugin over the network (which is how we enable/unlock the possibility to have language independent plugin implementations since by specifying `REMOTE` when importing a plugin, you can provide a network host where a plugin is deployed that was implemented in your preferred programming langugage rather than Typescript/Javascript for example.) Important note: When specifying `REMOTE` as the plugin import type, you still need to also specify the `packageName` property pointing to an npm package that has the API client class definition and the corresponding factory in it. The local implementation however does not have to be present in that npm package, which is the whole point. To provide a specific example of the above case: Writing a ledger connector plugin in a non-NodeJS language (Rust, Go, Java, etc.) can be done in the following way: 1. Define the API client for your plugin in Typescript (only needed if not already defined for the ledger of your choice) We recommend auto-generating this after having written a platform/language netural OpenAPI spec file first. This API client doesn't provide any actual implementation of your plugin, it just maps method names of your plugin to HTTP requests that your actual plugin implementation (in your language of choice) will have to be able to service. 2. Write the actual code of your plugin in your language of choice. 3. Profit. Also note: If you are re-implementing a connector plugin in a different language that already has an implementation in NodeJS/Typescript, then you can skip the step above that has you publish the npm package with the API client class and really only have to work in your language of choice. Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
Specifically for the in-memory and the vault plugin implementations. Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
This is partially a new feature, partially an example to demonstrate how one can develop a plugin written in in rust that then will be callable by other (non-rust) plugins that are hosted inside a Cactus node's API server(s). 99% of the rust code here was generated by the command below: docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate \ --input-spec https://raw.githubusercontent.com/petermetz/cactus/feat/cmd-api-server/out-of-process-plugin-Instances-for-language-Independence-170/packages/cactus-plugin-keychain-vault/src/main/json/openapi.json \ --generator-name rust-server \ -o /local/gen/rust-server The only thing that was then added to the generated rust code is the logic that uses the vault client create to do the get/set operations in vault and parses the environment variables for the vault token, host. Still a to-do for the above to have a proper has/delete method in the rust code which was not implemented due to time constraints. Also added a Typescript implementation of the vault keychain plugin just so that we can have a full end to end test coverage of all the variants of configurations where the plugin is local vs. remote. Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
petermetz
force-pushed
the
feat/out-of-process-plugin-instances-for-language-independence-170
branch
from
January 14, 2021 04:00
12389d0
to
7d83c60
Compare
🎉 Great news! Looks like all the dependencies have been resolved:
💡 To add or remove a dependency please update this issue/PR description. Brought to you by Dependent Issues (:robot: ). Happy coding! |
petermetz
deleted the
feat/out-of-process-plugin-instances-for-language-independence-170
branch
January 14, 2021 05:48
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
API_Server
dependencies
Pull requests that update a dependency file
Developer_Experience
enhancement
New feature or request
Security
Related to existing or potential security vulnerabilities
Significant_Change
Applying this label triggers the more stringent review of the maintainers and the 2+1 PR rule.
SPIKE
Exploratory work to better scope additional effort
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
How to Review
This PR depends on two others: #470 and #472 to ensure that the authors are not blocked in performing their work while waiting for the pull request to get reviewed. Please read the each point of the description below carefully!
Commit(s) to be reviewed:
Fixes #170
Depends on #470
Depends on #472