Giter Club home page Giter Club logo

brokersrv's Introduction

brokersrv: JSON-RPC 2.0 to NATS JetStream Gateway

Build Status Linter Status brokersrv rpc queue go Reference

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.

How to Use

  1. Configure brokersrv via TOML configuration and run it.
  2. Send RPC request to brokersrv.
  3. Use github.com/vmkteam/brokersrv/pkg/rpcqueue package in your RPC server for pulling RPC requests from NATS JetStream server.

Example

We have

  • testsrv test rpc server with zenrpc package as RPC server listen on localhost:8080/rpc/.
  • NATS JetStream server listen on localhost:4222.
  • brokersrv with following configuration:
[Server]
Host    = "localhost"
Port    = 8071

[NATS]
URL = "nats://localhost:4222"

[Settings]
RpcServices = [ "testsrv" ]

Use brokersrv package in testrpc for processing RPC requests from NATS JetStream Server

...

import (
    "github.com/nats-io/nats.go"
    "github.com/vmkteam/brokersrv/pkg/rpcqueue"
)

...

nc, err := nats.Connect("nats://localhost:4222", nats.Name("testsrv"), nats.MaxReconnects(100), nats.ReconnectWait(3*time.Second))

...

js, err := nc.JetStream()


...

rpcQueue := rpcqueue.New("testsrv", js, zenrpcSrv, someLoggerPrintF)

go rpcQueue.Run()

Send test RPC request

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.

brokersrv's People

Contributors

sas1024 avatar sergeyfast avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.