nproto

module
v0.11.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2020 License: MIT

README

NProto

GoDoc Go Report Build Status codecov

Some easy to use rpc/msg components.

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

Helper packages that can be used standalone

  • Task runner to contorl resource usage: taskrunner
  • CDC (Change Data Capture) for MySQL8+: mycanal

Install

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

Usage

  1. 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);
}
  1. If you want protoc-gen-nproto to generate stub code for your service to use with rpc components, add @@nprpc@@ at any position in the leading comment of the service.

  2. Likewise, if you want protoc-gen-nproto to generate stub code for your message to use with msg components, add @@npmsg@@ at any position in the leading comment of the message.

  3. Run protoc-gen-nproto, for example:

$ protoc --go_out=paths=source_relative:. --nproto_out=paths=source_relative:. *.proto
  1. Implement your service/message handler, then glue them with the stub code generated, see this simple exmaple for detail.

Directories

Path Synopsis
helpers
mycanal
Package mycanal is a CDC (Change Data Capture) library for MySQL8+ It provides helper functions for full dump (package fulldump) and incremental change capture (package incrdump).
Package mycanal is a CDC (Change Data Capture) library for MySQL8+ It provides helper functions for full dump (package fulldump) and incremental change capture (package incrdump).
mycanal/fulldump
Package fulldump provides helper functions for full dump.
Package fulldump provides helper functions for full dump.
mycanal/incrdump
Package incrdum provides helper functions for incremental change capture.
Package incrdum provides helper functions for incremental change capture.
taskrunner
Package taskrunner contains TaskRunner interface and some implementations.
Package taskrunner contains TaskRunner interface and some implementations.
Package nproto contains high level types and functions.
Package nproto contains high level types and functions.
binlogmsg
Package binlogmsg contains BinlogMsgPipe which is used as a publisher pipeline from MySQL-8 to downstream publisher.
Package binlogmsg contains BinlogMsgPipe which is used as a publisher pipeline from MySQL-8 to downstream publisher.
dbpipe
Package dbpipe contains DBMsgPublisherPipe which is used as a publisher pipeline from RDBMS to downstream publisher (deprecating).
Package dbpipe contains DBMsgPublisherPipe which is used as a publisher pipeline from RDBMS to downstream publisher (deprecating).
natsrpc
Package natsrpc contains NatsRPCServer/NatsRPCClient which implement nproto.RPCServer and nproto.RPCClient.
Package natsrpc contains NatsRPCServer/NatsRPCClient which implement nproto.RPCServer and nproto.RPCClient.
pb
stanmsg
Package stanmsg contains DurConn which implements nproto.MsgPublisher/nproto.MsgAsyncPublisher and nproto.MsgSubscriber.
Package stanmsg contains DurConn which implements nproto.MsgPublisher/nproto.MsgAsyncPublisher and nproto.MsgSubscriber.
tracing
Package tracing contains middlewares for RPCServer/RPCClient/MsgPublisher/MsgSubscriber to add opentracing support.
Package tracing contains middlewares for RPCServer/RPCClient/MsgPublisher/MsgSubscriber to add opentracing support.
tests

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL