Skip to content

fossabot/nproto

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NProto

GoDoc Go Report Build Status FOSSA 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.

License

FOSSA Status

About

Some easy to use rpc/msg components.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 99.8%
  • Makefile 0.2%