-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #271 from TykTechnologies/more-grpc
Add gRPC example using HTTP/2 over TCP
- Loading branch information
Showing
5 changed files
with
85 additions
and
2 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
deployments/tyk/data/tyk-dashboard/1/apis/api-oas-d76cfcb7f4d14c38419336a27c6ed9ca.json
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,43 @@ | ||
{ | ||
"components": {}, | ||
"info": { | ||
"title": "gRPC H2C", | ||
"version": "1.0.0" | ||
}, | ||
"openapi": "3.0.3", | ||
"paths": {}, | ||
"servers": [ | ||
{ | ||
"url": "http://tyk-gateway.localhost:8080/hello.HelloService/" | ||
} | ||
], | ||
"x-tyk-api-gateway": { | ||
"info": { | ||
"dbId": "66b4dec4ec7a380001d0085e", | ||
"id": "d76cfcb7f4d14c38419336a27c6ed9ca", | ||
"name": "gRPC H2C", | ||
"orgId": "5e9d9544a1dcd60001d0ed20", | ||
"state": { | ||
"active": true | ||
} | ||
}, | ||
"middleware": { | ||
"global": { | ||
"contextVariables": { | ||
"enabled": true | ||
}, | ||
"trafficLogs": { | ||
"enabled": true | ||
} | ||
} | ||
}, | ||
"server": { | ||
"listenPath": { | ||
"value": "/hello.HelloService/" | ||
} | ||
}, | ||
"upstream": { | ||
"url": "h2c://grpcbin:9000" | ||
} | ||
} | ||
} |
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 @@ | ||
|
||
#!/bin/bash | ||
|
||
# This example uses grpcurl to call a gRPC API service proxied by the Tyk gateway using HTTP/2 over TLS (h2c). | ||
|
||
# Check if grpcurl is installed | ||
if ! command -v grpcurl &> /dev/null | ||
then | ||
echo "grpcurl is not installed. Please install grpcurl to proceed:" | ||
echo "brew install grpcurl" | ||
exit 1 | ||
fi | ||
|
||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
PROTO_FILE="${SCRIPT_DIR}/hello.proto" | ||
|
||
echo "Call gRPC service using HTTP/2 over TLS (h2c)" | ||
grpcurl -plaintext -import-path "$SCRIPT_DIR" -proto "$PROTO_FILE" -d '{"greeting":"ralph"}' tyk-gateway.localhost:8080 hello.HelloService/SayHello |
2 changes: 1 addition & 1 deletion
2
deployments/tyk/scripts/examples/gRPC-api.sh → ...nts/tyk/scripts/examples/grpc/gRPC-tcp.sh
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,20 @@ | ||
// based on https://grpc.io/docs/guides/concepts.html | ||
|
||
syntax = "proto2"; | ||
|
||
package hello; | ||
|
||
service HelloService { | ||
rpc SayHello(HelloRequest) returns (HelloResponse); | ||
rpc LotsOfReplies(HelloRequest) returns (stream HelloResponse); | ||
rpc LotsOfGreetings(stream HelloRequest) returns (HelloResponse); | ||
rpc BidiHello(stream HelloRequest) returns (stream HelloResponse); | ||
} | ||
|
||
message HelloRequest { | ||
optional string greeting = 1; | ||
} | ||
|
||
message HelloResponse { | ||
required string reply = 1; | ||
} |
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