The ☁️ gRPC Proxy is an experimental project to code generate a proxy from Protobuf that enables you to use ☁️ services like AWS Lambda, Amazon DynamoDB) and more via gRPC. It combines the design by contract approach with the ease of the :cloud.
⚠️ the API of the project is not yet stable.⚠️ this is yet focused on AWS services
You provide your service definitions in Protobuf.
syntax = "proto3";
package proto;
import "google/protobuf/timestamp.proto";
import "api/annotations.proto";
// Example ...
service Example {
// Insert ...
rpc Insert(Insert.Request) returns (Insert.Response) {
option (amazon.api.methods).lambda = {
function_name: "arn:aws:lambda:us-east-2:123456789012:function:my-function:1"
};
};
// Update ...
rpc Update(Update.Request) returns (Update.Response) {
option (amazon.api.methods).dynamodb.UpdateItem = {
TableName: "aws-grpc-service-proxy"
ReturnValues: "ALL_NEW"
UpdateExpression: "SET #Y = :y, #AT = :t"
ExpressionAttributeNames: [
{ key: "key", value: "value" }
]
};
};
}
// Item ...
message Item {
// UUID ...
string uuid = 1;
// Title ...
string title = 2;
// Body ...
string body = 3;
}
// Insert ...
message Insert {
// Request ...
message Request {
Item item = 1;
}
// Response ...
message Response {
string uuid = 1;
}
}
// Update ...
message Update {
// Request ...
message Request {
Item item = 1;
}
// Response ...
message Response {
string uuid = 1;
}
}
The included plugin generates a fully functioning proxy from the Protobuf. The current code is generated in the Go programming language, but there is room for other languages.
If you want to compile the full example/example.proto you have to run the following command.
go build -o bin/protoc-gen-aws-service-proxy main.go && protoc --go_out=plugins=grpc:. --go_opt=paths=source_relative --aws-service-proxy_out=. --plugin=bin/protoc-gen-aws-service-proxy -I ./ example/example.proto
go get -u github.com/katallaxie/protoc-gen-cloud-proxy
There are several services waiting to be get supported
- AWS Lambda
- Amazon DynamoDB
- Amazon SQS
- Amazon SNS
- Amazon MSK