forked from hyperledger-cacti/cacti
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cmd-api-server): support grpc web services hyperledger-cacti#1189
Primary change: -------------- The API server now contains a gRPC server in addition to what it had before (HTTP+SocketIO servers) so that through this it can provide the opportunity for plugins to expose their gRPC services via the Cactus API server. It is possible for plugins to serve their requests on multiple protocols at the same time which means that this is a big step towards our goal of being properly multi- protocol capable. Secondary change(s): ------------------- 1. The "allowJs" flag for the Typescript compiler is now specified as true for the cmd-api-server package which is necessary because without this the .js files generated by protoc do not get copied over from the ./src/main/typescript/generated/ folder to the ./dist/lib/.../generated folder with the rest of the build files. It is not ideal that we are generating JS code into the TS folder but it does come with .d.ts files and this is the "state of the art" at the moment becaues we can only do what the protocol buffer compiler will support and this is it. Later on we should improve on this situation once the tooling catches up and adds support to generate straight up TS code instead of JS+d.ts files so that we keep to our convention of having only TS code under ./src/main/typescript for obvious reasons. TODO: ---- 1. Figure out how to stop the generator from mangling the model property names into capital case (getCreatedat) See: https://github.com/protocolbuffers/protobuf/issues/8608 2. Figure out how to export the OpenAPI model classes and the gRPC model classes at the same time without name conflicts (they have the same names) 3. Implement streaming healthcheck endpiont with gRPC 4. Allow plugins to hook in their own gRPC service implementations. 5. Verify with test case that the secure credentials flavor also works. Fixes hyperledger-cacti#1189 Signed-off-by: Peter Somogyvari <[email protected]>
- Loading branch information
Showing
58 changed files
with
1,718 additions
and
47 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 |
---|---|---|
|
@@ -14,3 +14,5 @@ | |
# **/coverage/** | ||
|
||
# typings/** | ||
|
||
**/src/main/typescript/generated/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
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
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
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
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
23 changes: 23 additions & 0 deletions
23
packages/cactus-cmd-api-server/src/main/proto/generated/openapi/.openapi-generator-ignore
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 @@ | ||
# OpenAPI Generator Ignore | ||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator | ||
|
||
# Use this file to prevent files from being overwritten by the generator. | ||
# The patterns follow closely to .gitignore or .dockerignore. | ||
|
||
# As an example, the C# client generator defines ApiClient.cs. | ||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: | ||
#ApiClient.cs | ||
|
||
# You can match any string of characters against a directory, file or extension with a single asterisk (*): | ||
#foo/*/qux | ||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux | ||
|
||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**): | ||
#foo/**/qux | ||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux | ||
|
||
# You can also negate patterns with an exclamation (!). | ||
# For example, you can ignore all files in a docs folder with the file extension .md: | ||
#docs/*.md | ||
# Then explicitly reverse the ignore rule for a single file: | ||
#!docs/README.md |
5 changes: 5 additions & 0 deletions
5
packages/cactus-cmd-api-server/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,5 @@ | ||
README.md | ||
models/health_check_response.proto | ||
models/memory_usage.proto | ||
models/watch_healthcheck_v1.proto | ||
services/default_service.proto |
1 change: 1 addition & 0 deletions
1
packages/cactus-cmd-api-server/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 @@ | ||
5.1.1 |
31 changes: 31 additions & 0 deletions
31
packages/cactus-cmd-api-server/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.cactus.cmd_api_server | ||
|
||
Interact with a Cactus deployment through HTTP. | ||
|
||
## Overview | ||
These files were generated by the [OpenAPI Generator](https://openapi-generator.tech) project. | ||
|
||
- API version: 0.0.1 | ||
- 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/ | ||
protoc --go_out=/var/tmp/go/ services/* | ||
protoc --go_out=/var/tmp/go/ models/* | ||
``` | ||
|
||
### Ruby | ||
``` | ||
# assuming `grpc_tools_ruby_protoc` has been installed via `gem install grpc-tools` | ||
RUBY_OUTPUT_DIR="/var/tmp/ruby/org.hyperledger.cactus.cmd_api_server" | ||
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/* | ||
``` |
25 changes: 25 additions & 0 deletions
25
...cactus-cmd-api-server/src/main/proto/generated/openapi/models/health_check_response.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,25 @@ | ||
/* | ||
Hyperledger Cactus API | ||
Interact with a Cactus deployment through HTTP. | ||
The version of the OpenAPI document: 0.0.1 | ||
Generated by OpenAPI Generator: https://openapi-generator.tech | ||
*/ | ||
|
||
syntax = "proto3"; | ||
|
||
package org.hyperledger.cactus.cmd_api_server; | ||
|
||
import public "models/memory_usage.proto"; | ||
|
||
message HealthCheckResponse { | ||
|
||
bool success = 256557056; | ||
|
||
string createdAt = 61500732; | ||
|
||
MemoryUsage memoryUsage = 335792418; | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
packages/cactus-cmd-api-server/src/main/proto/generated/openapi/models/memory_usage.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,28 @@ | ||
/* | ||
Hyperledger Cactus API | ||
Interact with a Cactus deployment through HTTP. | ||
The version of the OpenAPI document: 0.0.1 | ||
Generated by OpenAPI Generator: https://openapi-generator.tech | ||
*/ | ||
|
||
syntax = "proto3"; | ||
|
||
package org.hyperledger.cactus.cmd_api_server; | ||
|
||
|
||
message MemoryUsage { | ||
|
||
float rss = 113234; | ||
|
||
float heapTotal = 114487480; | ||
|
||
float heapUsed = 30910521; | ||
|
||
float external = 210148408; | ||
|
||
float arrayBuffers = 116952168; | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
.../cactus-cmd-api-server/src/main/proto/generated/openapi/models/watch_healthcheck_v1.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,18 @@ | ||
/* | ||
Hyperledger Cactus API | ||
Interact with a Cactus deployment through HTTP. | ||
The version of the OpenAPI document: 0.0.1 | ||
Generated by OpenAPI Generator: https://openapi-generator.tech | ||
*/ | ||
|
||
syntax = "proto3"; | ||
|
||
package org.hyperledger.cactus.cmd_api_server; | ||
|
||
|
||
message WatchHealthcheckV1 { | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
...ges/cactus-cmd-api-server/src/main/proto/generated/openapi/services/default_service.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,28 @@ | ||
/* | ||
Hyperledger Cactus API | ||
Interact with a Cactus deployment through HTTP. | ||
The version of the OpenAPI document: 0.0.1 | ||
Generated by OpenAPI Generator: https://openapi-generator.tech | ||
*/ | ||
|
||
syntax = "proto3"; | ||
|
||
package org.hyperledger.cactus.cmd_api_server; | ||
|
||
import "google/protobuf/empty.proto"; | ||
import public "models/health_check_response.proto"; | ||
|
||
service DefaultService { | ||
rpc GetHealthCheckV1 (google.protobuf.Empty) returns (HealthCheckResponse); | ||
|
||
rpc GetPrometheusMetricsV1 (google.protobuf.Empty) returns (GetPrometheusMetricsV1Response); | ||
|
||
} | ||
|
||
message GetPrometheusMetricsV1Response { | ||
string data = 1; | ||
} | ||
|
Oops, something went wrong.