-
Notifications
You must be signed in to change notification settings - Fork 6
Add documentation for gateway node-type #134
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
Open
al3xa23
wants to merge
12
commits into
master
Choose a base branch
from
node-gateway
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c2cbc19
Add gateway node-type documentation
JitpanuM 1236b03
Add gateway node docu Co-authored-by: Jitpanu Maneeratpongsuk <jitpan…
al3xa23 0ea4ec8
Update docs/node/nodes/gateway.md
al3xa23 2bbf18f
Update docs/node/nodes/gateway.md
al3xa23 5de12d3
Update docs/node/nodes/gateway.md
al3xa23 9d1963b
Update docs/node/nodes/gateway.md
al3xa23 40b0a5e
Update docs/node/nodes/gateway.md
al3xa23 22c7201
Update docs/node/nodes/gateway.md
al3xa23 3058233
Update docs/node/nodes/gateway.md
al3xa23 be25d5d
Update docs/node/nodes/gateway.md
al3xa23 4bd605e
Update docs/node/nodes/gateway.md
al3xa23 f070097
node-gateway: address review
al3xa23 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,124 @@ | ||
| --- | ||
| sidebar_label: Gateway | ||
| hide_table_of_contents: true | ||
| --- | ||
|
|
||
| # Gateway | ||
|
|
||
| The `gateway` node-type enables VILLASnode to translate between Application Programmable Interfaces (API) types. | ||
| Currently, the transformation of [HTTP](https://en.wikipedia.org/wiki/HTTP) and [gRPC](https://grpc.io/) is supported. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| This node-type requires [gRPC](https://grpc.io/) and [reflection.proto](https://github.com/grpc/grpc/blob/master/src/proto/grpc/reflection/v1alpha/reflection.proto) for gRPC server [reflection](https://grpc.io/docs/guides/reflection/). | ||
| The script `packaging/deps.sh` can be used to automatically download reflection.proto and generate protobuf code. | ||
| Please refer to the [installation document](../installation.md). | ||
|
|
||
| ## Implementation | ||
|
|
||
| The source code of the node-type is available here: | ||
| https://github.com/VILLASframework/node/blob/master/lib/nodes/gateway.cpp | ||
|
|
||
| ### Limitations | ||
|
|
||
| - The `gateway` node-type only supportes unary RPC. | ||
|
|
||
| ## Configuration {#config} | ||
|
|
||
| import ApiSchema from '@theme/ApiSchema'; | ||
|
|
||
| <ApiSchema id="node" example pointer="#/components/schemas/api" /> | ||
|
|
||
| ## Example | ||
|
|
||
| ``` url="external/node/etc/examples/nodes/gateway.conf" title="node/etc/examples/nodes/api.conf" | ||
| http = { | ||
| port = 8080 | ||
| } | ||
|
|
||
| nodes = { | ||
| gateway_node = { | ||
| type = "gateway" | ||
|
|
||
| format = "protobuf" | ||
| # API type | ||
| gateway_type = "gRPC" | ||
| # Address of remote server | ||
| address = "localhost:50051" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| The usage of this node is similar to [`api`](api.md) node-type. | ||
| The following [`curl`](https://curl.se/) commands are examples for calling gRPC methods via the HTTP API. | ||
| The input for a gRPC call can be either the body of HTTP request or input data from another node (via a [path](../config/paths.md)). | ||
| If the http request body is empty, the input from other node will be used. | ||
|
|
||
| Since this node-type does not implement the gRPC server, it needs to be added manually. A description is available [1]. | ||
|
|
||
| Note on HTTP methods | ||
| - GET should be used only when the input of gRPC method can be empty or ignored. | ||
| - PUT should be used when the output of gRPC method is in VILLASnode format and the user want to put the data to the path. | ||
| - POST should be used when the output of gRPC method is not in VILLASnode format or the user not want output data to the path. | ||
|
|
||
| ### General Request | ||
|
|
||
| The URL for sending a request to the gateway node-type is as following: | ||
| ``` | ||
| http://<address>:<port>/api/v2/gateway/<node name or UUID>/<gRPC package>/<gRPC service>/<gRPC method> | ||
| ``` | ||
|
|
||
| The following `server.proto` file will be used as an example which imports the already existing [`villas.proto`](https://github.com/VILLASframework/node/blob/master/lib/formats/villas.proto) data format. | ||
| ``` | ||
| syntax = "proto3"; | ||
|
|
||
| import "villas.proto"; | ||
|
|
||
| package ex_server; | ||
|
|
||
| service ex_service { | ||
| rpc GetData (villas.node.Message) returns (villas.node.Message) {}; | ||
| rpc SetData (villas.node.Message) returns (msg) {}; | ||
| rpc GetDataRef (Reference) returns (villas.node.Message) {}; | ||
| } | ||
|
|
||
| message Reference { | ||
| repeated int32 ref = 1; | ||
| } | ||
|
|
||
| message msg { | ||
| string status = 1; | ||
| } | ||
|
|
||
| ``` | ||
|
|
||
| ### Call `GetData` method on gRPC server | ||
| The `GetData` method writes the data from gRPC server to the VILLASnode path. | ||
| It uses the PUT method. | ||
|
|
||
| ```shell | ||
| curl http://localhost:8080/api/v2/gateway/gateway_node/ex_server/ex_service/GetData -XPUT | ||
| ``` | ||
|
|
||
| ### Call `SetData` method on gRPC server | ||
| The `SetData` method writes the data from the VILLASnode path to the gRPC server. | ||
| No data is given in the request body. | ||
| It uses the POST method. | ||
|
|
||
| ```shell | ||
| curl http://localhost:8080/api/v2/gateway/gateway_node/ex_server/ex_service/SetData -XPOST | ||
| ``` | ||
|
|
||
| ### Call `GetDataRef` method on gRPC server | ||
| The `GetDataRef` method requests data of the gRPC based on input references, e.g., referring to nodes in the simulation. | ||
| The body provides a protobuf payload based on the example `.proto` file. | ||
| VILLASnode send the request to the gRPC server. | ||
|
|
||
| ```shell | ||
| curl http://localhost:8080/api/v2/gateway/gateway_node/ex_server/ex_service/GetDataRef -d '{"ref":[0,1,2,3,4]}' | ||
| ``` | ||
|
|
||
| # Reference | ||
| [1] Jitpanu Maneeratpongsuk, "Enhancing Interoperability and Automation in Co-Simulations: An API Gateway Approach for VILLASnode," [Online]. Available: https://www.acs.eonerc.rwth-aachen.de/global/show_document.asp?id=aaaaaaaadidaesd | ||
This file contains hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.