brokersrv is a transparent gateway on top of JSON-RPC 2.0 server that's passes RPC requests to NATS JetStream server.
It uses zenrpc package for processing RPC requests.
- Configure brokersrv via TOML configuration and run it.
- Send RPC request to brokersrv.
- Use
github.com/vmkteam/brokersrv/pkg/rpcqueuepackage in your RPC server for pulling RPC requests from NATS JetStream server.
testsrvtest rpc server with zenrpc package as RPC server listen onlocalhost:8080/rpc/.NATS JetStream serverlisten onlocalhost:4222.brokersrvwith following configuration:
[Server]
Host = "localhost"
Port = 8071
[NATS]
URL = "nats://localhost:4222"
[Settings]
RpcServices = [ "testsrv" ]...
import (
"github.com/vmkteam/brokersrv/pkg/rpcqueue"
)
...
nc, err := rpcqueue.NewClient("nats://localhost:4222", "testsrv")
...
rpcQueue := rpcqueue.New("testsrv", nc.JetStreamConn, zenrpcSrv, someLoggerPrintF)
go rpcQueue.Run()Just send RPC request to localhost:8071/rpc/testsrv/ via Postman/curl. This request will pass into NATS JetStream server.
After that rpcQueue in testsrv will fetch this request from NATS JetStream server and pass it to own RPC server.