Code Monkey home page Code Monkey logo

jussi's Introduction

jussi

A reverse proxy that only speaks json-rpc 2.0. Upstream routing is done using json-rpc method "namespaces".

Namespaces

A json-rpc method namespace is a json-rpc method prefix joined to the method name with a period, so a method in the "sbds" namespace begins with sbds. and will be forwarded to a sbds endpoint:

POST / HTTP/1.1
Content-Type: application/json

{
  "method": "sbds.count_operations",
  "params": {"operation":"account_creates"},
  "jsonrpc": "2.0",
  "id": 1
}

Default Namespace

Any json-rpc method with no period in the method name is presumed to be in the "steemd" namespace and will be forwarded to a steemd endpoint:

POST / HTTP/1.1
Content-Type: application/json

{
  "method": "get_block",
  "params": [1],
  "jsonrpc": "2.0",
  "id": 1
}

What jussi does

At Startup

  1. parse the upstream config and build the routing, caching, timeout data structures
  2. open websocket and/or http connections to upstreams
  3. initialize memory cache and open connections to redis cache
  4. register route and error handlers

Request/Response Cycle

  1. validate jsonrpc request
  2. convert individual jsonrpc requests into JSONRPCRequest objects, which add its pseudo-urn and upstream configuration
  3. generate cache key (pseudo-urn for the moment)
  4. if a single jsonrpc request:
    1. check in-memory cache, if miss
    2. make a redis get call
  5. if a batch call:
    1. check in-memory cache for all keys
    2. for any misses:
    3. make a redis mget request for any keys not found in memory cache
  6. if all data loaded from cache:
    1. merge cached data with requests to form response
    2. send response
  7. if any jsonrpc call results aren't in cache:
  8. determine which upstream url and protocol (websockets or http) to use to fetch them
  9. start upsteam request timers
  10. fetch missing jsonrpc calls
  11. end upstream response timers
  12. decide if response is a valid jsonrpc response and that it is not a jsonrpc error response
  13. if response is valid, and response is not a jsonrpc error response, determine the cache ttl for that jsonrpc namespace.method
  14. for some calls, verify the the response is a consensus response or not, and modify cache ttl for irreversible block responses
  15. return single jsonrpc response or assembled jsonrpc responses for batch requests
  16. cache response in redis cache
  17. cache response in memory

jussi's People

Contributors

john-g-g avatar jredbeard avatar jnordberg avatar sneak avatar roadscape avatar prcolaco avatar

Watchers

James Cloos avatar Mahdi Yari 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.