Skip to content

Latest commit

 

History

History
71 lines (52 loc) · 1.78 KB

README.md

File metadata and controls

71 lines (52 loc) · 1.78 KB

jsonrpc-proxy Build and Release

Quick Start

Install

go install github.com/revolution1/jsonrpc-proxy

#or

curl -L https://github.com/Revolution1/jsonrpc-proxy/releases/latest/download/jsonrpc-proxy-Darwin-amd64 -o jsonrpc-proxy
chmod +x jsonrpc-proxy

Edit Config and Run

Download config file from https://github.com/Revolution1/jsonrpc-proxy/raw/main/proxy.yaml

Run

jsonrpc-proxy -c proxy.yaml

Test

$ curl http://loclahost:8080 -X POST -d '{"id":1,"jsonrpc":"2.0","method":"GetBlockchainInfo","params":[]}'

Request Processing & Caching Policy

path not match:
\_ return 404 Not Found
path match:
\_ invalid json: return -32700 Parse Error
\_ valid json
   \_ one request & jsonrpc invalid: return -32600 Invalid Request
   \_ valid jsonrpc
      \_ one request:
         \_ cached: return cached response
         \_ not cached: forward to upstream
            \_ net|http|jsonrpc error: cache error for 'ErrFor' duration
            \_ success: cache for 'for' duration and return
      \_ batch request:
         \_ all invalid: return errors
         \_ all cached: return cached responses
         \_ not all cached: forward whole batch to upstream
            \_ net|http error: cache error for 'ErrFor' duration
            \_ jsonrpc error: cache errored request for it's 'ErrFor' duration
            \_ success: cache for it's 'for' duration and return

TODO

  • batch request
  • k8s service discovery
  • cache notfound error
  • method statistics
  • account based rate limiting
  • epoch based retry & loadbalancing
  • modularize
  • easyjson & msgp

ref

https://www.jsonrpc.org/historical/json-rpc-over-http.html