-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(plugin-keychain-memory): add ConnectRPC support
1. This leverages the newly introduced methods in core-api that the API server is using to probe if a plugin has ConnectRPC support or not. 2. There is support for both HTTP 1.1 and HTTP 2. The caveat here is that HTTP 2 is not supported by ExpressJS so we pulled in Fastify to handle those type of requests and that means that HTTP 2 ConnectRPC traffic has to go through a different port compared to the HTTP 1.1 ConnectRPC traffic. 3. The lesson here is that we probably need to migrate away from ExpressJS longer term because it does not (and from the looks of it will not ever) support HTTP 2 which is probably going to be a bit of technical debt/ limiting factor in architectural decisions going forward for both Cacti maintainers and Cacti users. 4. A new code generator has been introduced by this commit as well which is @buf/build - the tool where ConnectRPC originates from. The scripts are structured in such a way that this should be seamlessly integrated into the existing `codegen` root level script and therefore also the CI. 5. There is test coverage for both HTTP 1.1 and HTTP 2 traffic in the file at ```sh packages/cactus-test-plugin-keychain-memory/src/test/typescript/integration/ test-keychain-memory-crpc-api-server.test.ts ``` 6. The test case referenced above is also the example on how to use the ConnectRPC client (very similar to the HTTP client we already had before) Depends on #3183 Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
- Loading branch information
Showing
44 changed files
with
2,261 additions
and
5 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# buf.gen.yaml defines a local generation template. | ||
# For details, see https://buf.build/docs/configuration/v1/buf-gen-yaml | ||
version: v1 | ||
plugins: | ||
# This will invoke protoc-gen-es and write output to src/gen | ||
- plugin: es | ||
# packages/cactus-plugin-keychain-memory/src/main/typescript/generated/protoc-gen-es | ||
out: ../../crpc | ||
opt: | ||
# Add more plugin options here | ||
- target=ts | ||
# This will invoke protoc-gen-connect-es | ||
- plugin: connect-es | ||
# packages/cactus-plugin-keychain-memory/src/main/typescript/generated/protoc-gen-connect-es | ||
out: ../../crpc | ||
opt: | ||
# Add more plugin options here | ||
- target=ts |
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
46 changes: 46 additions & 0 deletions
46
...eychain-memory/src/main/mustache/openapi-generator/templates/protobuf-schema/api.mustache
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{{>partial_header}} | ||
syntax = "proto3"; | ||
|
||
package {{#lambda.lowercase}}{{{packageName}}}.{{{apiPackage}}}.{{{classname}}};{{/lambda.lowercase}} | ||
|
||
import "google/protobuf/empty.proto"; | ||
{{#imports}} | ||
{{#import}} | ||
import "{{{modelPackage}}}/{{{.}}}.proto"; | ||
{{/import}} | ||
{{/imports}} | ||
|
||
service {{classname}} { | ||
{{#operations}} | ||
{{#operation}} | ||
{{#description}} | ||
// {{{.}}} | ||
{{/description}} | ||
rpc {{operationId}} ({{#hasParams}}{{operationId}}Request{{/hasParams}}{{^hasParams}}google.protobuf.Empty{{/hasParams}}) returns ({{#vendorExtensions.x-grpc-response}}{{.}}{{/vendorExtensions.x-grpc-response}}{{^vendorExtensions.x-grpc-response}}{{operationId}}Response{{/vendorExtensions.x-grpc-response}}); | ||
|
||
{{/operation}} | ||
{{/operations}} | ||
} | ||
|
||
{{#operations}} | ||
{{#operation}} | ||
{{#hasParams}} | ||
message {{operationId}}Request { | ||
{{#allParams}} | ||
{{#description}} | ||
// {{{.}}} | ||
{{/description}} | ||
{{#vendorExtensions.x-protobuf-type}}{{.}} {{/vendorExtensions.x-protobuf-type}}{{vendorExtensions.x-protobuf-data-type}} {{paramName}} = {{vendorExtensions.x-protobuf-index}}; | ||
{{/allParams}} | ||
|
||
} | ||
|
||
{{/hasParams}} | ||
{{^vendorExtensions.x-grpc-response}} | ||
message {{operationId}}Response { | ||
{{{vendorExtensions.x-grpc-response-type}}} data = 1; | ||
} | ||
|
||
{{/vendorExtensions.x-grpc-response}} | ||
{{/operation}} | ||
{{/operations}} |
41 changes: 41 additions & 0 deletions
41
...chain-memory/src/main/mustache/openapi-generator/templates/protobuf-schema/model.mustache
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{{>partial_header}} | ||
syntax = "proto3"; | ||
|
||
package {{#lambda.lowercase}}{{{packageName}}};{{/lambda.lowercase}} | ||
|
||
import "google/protobuf/any.proto"; | ||
|
||
{{#imports}} | ||
{{#import}} | ||
import "{{{modelPackage}}}/{{{import}}}.proto"; | ||
{{/import}} | ||
{{/imports}} | ||
|
||
{{#models}} | ||
{{#model}} | ||
{{#isEnum}}{{>enum}}{{/isEnum}}{{^isEnum}}message {{classname}} { | ||
{{#vars}} | ||
{{#description}} | ||
// {{{.}}} | ||
{{/description}} | ||
{{^isEnum}} | ||
{{#vendorExtensions.x-protobuf-type}}{{{.}}} {{/vendorExtensions.x-protobuf-type}}{{{vendorExtensions.x-protobuf-data-type}}} {{{name}}} = {{vendorExtensions.x-protobuf-index}}{{#vendorExtensions.x-protobuf-packed}} [packed=true]{{/vendorExtensions.x-protobuf-packed}}; | ||
{{/isEnum}} | ||
{{#isEnum}} | ||
enum {{enumName}} { | ||
{{#allowableValues}} | ||
{{#enumVars}} | ||
{{{name}}} = {{{protobuf-enum-index}}}; | ||
{{/enumVars}} | ||
{{/allowableValues}} | ||
} | ||
|
||
{{enumName}} {{name}} = {{vendorExtensions.x-protobuf-index}}; | ||
{{/isEnum}} | ||
|
||
{{/vars}} | ||
} | ||
{{/isEnum}} | ||
{{/model}} | ||
{{/models}} |
22 changes: 22 additions & 0 deletions
22
...ychain-memory/src/main/mustache/openapi-generator/templates/protobuf-schema/root.mustache
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{{>partial_header}} | ||
syntax = "proto3"; | ||
|
||
package {{{packageName}}}; | ||
|
||
{{#vendorExtensions.x-grpc-options}} | ||
option {{{.}}}; | ||
{{/vendorExtensions.x-grpc-options}} | ||
|
||
// Models | ||
{{#models}} | ||
{{#model}} | ||
import "{{modelPackage}}/{{classFilename}}.proto"; | ||
{{/model}} | ||
{{/models}} | ||
|
||
// APIs | ||
{{#apiInfo}} | ||
{{#apis}} | ||
import "{{apiPackage}}/{{classFilename}}.proto"; | ||
{{/apis}} | ||
{{/apiInfo}} |
10 changes: 10 additions & 0 deletions
10
...s/cactus-plugin-keychain-memory/src/main/proto/generated/openapi/.openapi-generator/FILES
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
README.md | ||
models/delete_keychain_entry_request_v1_pb.proto | ||
models/delete_keychain_entry_response_v1_pb.proto | ||
models/get_keychain_entry_request_v1_pb.proto | ||
models/get_keychain_entry_response_v1_pb.proto | ||
models/has_keychain_entry_request_v1_pb.proto | ||
models/has_keychain_entry_response_v1_pb.proto | ||
models/set_keychain_entry_request_v1_pb.proto | ||
models/set_keychain_entry_response_v1_pb.proto | ||
services/default_service.proto |
1 change: 1 addition & 0 deletions
1
...cactus-plugin-keychain-memory/src/main/proto/generated/openapi/.openapi-generator/VERSION
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
6.6.0 |
31 changes: 31 additions & 0 deletions
31
packages/cactus-plugin-keychain-memory/src/main/proto/generated/openapi/README.md
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# gPRC for org.hyperledger.cacti.plugin.keychain.memory | ||
|
||
Contains/describes the Hyperledger Cacti Keychain Memory plugin. | ||
|
||
## Overview | ||
These files were generated by the [OpenAPI Generator](https://openapi-generator.tech) project. | ||
|
||
- API version: v2.0.0-alpha.2 | ||
- Package version: | ||
- Build package: org.openapitools.codegen.languages.ProtobufSchemaCodegen | ||
|
||
## Usage | ||
|
||
Below are some usage examples for Go and Ruby. For other languages, please refer to https://grpc.io/docs/quickstart/. | ||
|
||
### Go | ||
``` | ||
# assuming `protoc-gen-go` has been installed with `go get -u github.com/golang/protobuf/protoc-gen-go` | ||
mkdir /var/tmp/go/org.hyperledger.cacti.plugin.keychain.memory | ||
protoc --go_out=/var/tmp/go/org.hyperledger.cacti.plugin.keychain.memory services/* | ||
protoc --go_out=/var/tmp/go/org.hyperledger.cacti.plugin.keychain.memory models/* | ||
``` | ||
|
||
### Ruby | ||
``` | ||
# assuming `grpc_tools_ruby_protoc` has been installed via `gem install grpc-tools` | ||
RUBY_OUTPUT_DIR="/var/tmp/ruby/org.hyperledger.cacti.plugin.keychain.memory" | ||
mkdir $RUBY_OUTPUT_DIR | ||
grpc_tools_ruby_protoc --ruby_out=$RUBY_OUTPUT_DIR --grpc_out=$RUBY_OUTPUT_DIR/lib services/* | ||
grpc_tools_ruby_protoc --ruby_out=$RUBY_OUTPUT_DIR --grpc_out=$RUBY_OUTPUT_DIR/lib models/* | ||
``` |
23 changes: 23 additions & 0 deletions
23
...-memory/src/main/proto/generated/openapi/models/delete_keychain_entry_request_v1_pb.proto
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
Hyperledger Cactus Plugin - Keychain Memory | ||
Contains/describes the Hyperledger Cacti Keychain Memory plugin. | ||
The version of the OpenAPI document: v2.0.0-alpha.2 | ||
Generated by OpenAPI Generator: https://openapi-generator.tech | ||
*/ | ||
|
||
syntax = "proto3"; | ||
|
||
package org.hyperledger.cacti.plugin.keychain.memory; | ||
|
||
import "google/protobuf/any.proto"; | ||
|
||
|
||
message DeleteKeychainEntryRequestV1PB { | ||
|
||
// The key for the entry to check the presence of on the keychain. | ||
string key = 106079; | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
...memory/src/main/proto/generated/openapi/models/delete_keychain_entry_response_v1_pb.proto
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
Hyperledger Cactus Plugin - Keychain Memory | ||
Contains/describes the Hyperledger Cacti Keychain Memory plugin. | ||
The version of the OpenAPI document: v2.0.0-alpha.2 | ||
Generated by OpenAPI Generator: https://openapi-generator.tech | ||
*/ | ||
|
||
syntax = "proto3"; | ||
|
||
package org.hyperledger.cacti.plugin.keychain.memory; | ||
|
||
import "google/protobuf/any.proto"; | ||
|
||
|
||
message DeleteKeychainEntryResponseV1PB { | ||
|
||
// The key that was deleted from the keychain. | ||
string key = 106079; | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
...ain-memory/src/main/proto/generated/openapi/models/get_keychain_entry_request_v1_pb.proto
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
Hyperledger Cactus Plugin - Keychain Memory | ||
Contains/describes the Hyperledger Cacti Keychain Memory plugin. | ||
The version of the OpenAPI document: v2.0.0-alpha.2 | ||
Generated by OpenAPI Generator: https://openapi-generator.tech | ||
*/ | ||
|
||
syntax = "proto3"; | ||
|
||
package org.hyperledger.cacti.plugin.keychain.memory; | ||
|
||
import "google/protobuf/any.proto"; | ||
|
||
|
||
message GetKeychainEntryRequestV1PB { | ||
|
||
// The key for the entry to get from the keychain. | ||
string key = 106079; | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
...in-memory/src/main/proto/generated/openapi/models/get_keychain_entry_response_v1_pb.proto
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
Hyperledger Cactus Plugin - Keychain Memory | ||
Contains/describes the Hyperledger Cacti Keychain Memory plugin. | ||
The version of the OpenAPI document: v2.0.0-alpha.2 | ||
Generated by OpenAPI Generator: https://openapi-generator.tech | ||
*/ | ||
|
||
syntax = "proto3"; | ||
|
||
package org.hyperledger.cacti.plugin.keychain.memory; | ||
|
||
import "google/protobuf/any.proto"; | ||
|
||
|
||
message GetKeychainEntryResponseV1PB { | ||
|
||
// The key that was used to retrieve the value from the keychain. | ||
string key = 106079; | ||
|
||
// The value associated with the requested key on the keychain. | ||
string value = 111972721; | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
...ain-memory/src/main/proto/generated/openapi/models/has_keychain_entry_request_v1_pb.proto
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
Hyperledger Cactus Plugin - Keychain Memory | ||
Contains/describes the Hyperledger Cacti Keychain Memory plugin. | ||
The version of the OpenAPI document: v2.0.0-alpha.2 | ||
Generated by OpenAPI Generator: https://openapi-generator.tech | ||
*/ | ||
|
||
syntax = "proto3"; | ||
|
||
package org.hyperledger.cacti.plugin.keychain.memory; | ||
|
||
import "google/protobuf/any.proto"; | ||
|
||
|
||
message HasKeychainEntryRequestV1PB { | ||
|
||
// The key to check for presence in the keychain. | ||
string key = 106079; | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
...in-memory/src/main/proto/generated/openapi/models/has_keychain_entry_response_v1_pb.proto
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
Hyperledger Cactus Plugin - Keychain Memory | ||
Contains/describes the Hyperledger Cacti Keychain Memory plugin. | ||
The version of the OpenAPI document: v2.0.0-alpha.2 | ||
Generated by OpenAPI Generator: https://openapi-generator.tech | ||
*/ | ||
|
||
syntax = "proto3"; | ||
|
||
package org.hyperledger.cacti.plugin.keychain.memory; | ||
|
||
import "google/protobuf/any.proto"; | ||
|
||
|
||
message HasKeychainEntryResponseV1PB { | ||
|
||
// The key that was used to check the presence of the value in the entry store. | ||
string key = 106079; | ||
|
||
// Date and time encoded as JSON when the presence check was performed by the plugin backend. | ||
string checkedAt = 399084090; | ||
|
||
// The boolean true or false indicating the presence or absence of an entry under 'key'. | ||
bool isPresent = 361185232; | ||
|
||
} |
Oops, something went wrong.