-
Notifications
You must be signed in to change notification settings - Fork 285
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 #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. Custom protobuf-schema openapi generator template added because of this issue: thesayyn/protoc-gen-ts#82 (we override the stock template to not use the public keyword) TODO: ---- 1. Implement streaming healthcheck endpiont with gRPC 2. Allow plugins to hook in their own gRPC service implementations. Fixes #1189 Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
- Loading branch information
Showing
54 changed files
with
1,225 additions
and
39 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
46 changes: 46 additions & 0 deletions
46
...s/cactus-cmd-api-server/src/main/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 {{{packageName}}}; | ||
|
||
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}} |
37 changes: 37 additions & 0 deletions
37
...cactus-cmd-api-server/src/main/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,37 @@ | ||
{{>partial_header}} | ||
syntax = "proto3"; | ||
|
||
package {{{packageName}}}; | ||
|
||
{{#imports}} | ||
{{#import}} | ||
import "{{{modelPackage}}}/{{{import}}}.proto"; | ||
{{/import}} | ||
{{/imports}} | ||
|
||
{{#models}} | ||
{{#model}} | ||
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}} | ||
} | ||
{{/model}} | ||
{{/models}} |
22 changes: 22 additions & 0 deletions
22
.../cactus-cmd-api-server/src/main/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}} |
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 |
6 changes: 6 additions & 0 deletions
6
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,6 @@ | ||
.openapi-generator-ignore | ||
README.md | ||
models/health_check_response_pb.proto | ||
models/memory_usage_pb.proto | ||
models/watch_healthcheck_v1_pb.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/* | ||
``` |
24 changes: 24 additions & 0 deletions
24
...tus-cmd-api-server/src/main/proto/generated/openapi/models/health_check_response_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,24 @@ | ||
/* | ||
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 "models/memory_usage_pb.proto"; | ||
|
||
message HealthCheckResponsePB { | ||
bool success = 256557056; | ||
|
||
string createdAt = 61500732; | ||
|
||
MemoryUsagePB memoryUsage = 335792418; | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
packages/cactus-cmd-api-server/src/main/proto/generated/openapi/models/memory_usage_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,27 @@ | ||
/* | ||
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 MemoryUsagePB { | ||
float rss = 113234; | ||
|
||
float heapTotal = 114487480; | ||
|
||
float heapUsed = 30910521; | ||
|
||
float external = 210148408; | ||
|
||
float arrayBuffers = 116952168; | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
...ctus-cmd-api-server/src/main/proto/generated/openapi/models/watch_healthcheck_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,17 @@ | ||
/* | ||
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 WatchHealthcheckV1PB { | ||
} |
Oops, something went wrong.