Some easy to use rpc/msg components.
- High level interfaces nproto
- RPC server/client using nats as transport with json/protobuf encoding: natsrpc
- Auto reconnection/resubscription client for nats-streaming: stanmsg
- Pipeline msgs from RDBMS to downstream publisher (deprecating): dbpipe
- Pipeline msgs from MySQL8 binlog to downstream publisher: binlogmsg
- Opentracing support: tracing
- Structure (json) logging support using zerolog: zlog
- Protoc plugin to generate stub code for above components: protoc-gen-nproto
- Task runner to contorl resource usage: taskrunner
- CDC (Change Data Capture) for MySQL8+: mycanal
You need to install protobuf's compiler and protoc-gen-go first.
To install libraries, run: $ go get -u github.com/huangjunwen/nproto/nproto/...
To install the protoc plugin, run: $ go get -u github.com/huangjunwen/nproto/protoc-gen-nproto
- As always you needs to write a proto file, for example:
syntax = "proto3";
package huangjunwen.nproto.tests.mathapi;
option go_package = "github.com/huangjunwen/nproto/tests/math/api;mathapi";
message SumRequest {
repeated double args = 1;
}
message SumReply {
double sum = 1;
}
// Math is a service providing some math functions.
// @@nprpc@@
service Math {
// Sum returns the sum of a list of arguments.
rpc Sum(SumRequest) returns (SumReply);
}-
If you want
protoc-gen-nprototo generate stub code for your service to use with rpc components, add@@nprpc@@at any position in the leading comment of the service. -
Likewise, if you want
protoc-gen-nprototo generate stub code for your message to use with msg components, add@@npmsg@@at any position in the leading comment of the message. -
Run
protoc-gen-nproto, for example:
$ protoc --go_out=paths=source_relative:. --nproto_out=paths=source_relative:. *.proto- Implement your service/message handler, then glue them with the stub code generated, see this simple exmaple for detail.