GithubHelp home page GithubHelp logo

surendra-patil / cosmos-cache Goto Github PK

View Code? Open in Web Editor NEW

This project forked from reecepbcups/cosmos-cache

0.0 0.0 0.0 546 KB

Caches Cosmos RPC/API calls for configurable periods of time

Shell 6.76% Python 90.17% Makefile 0.75% Dockerfile 2.32%

cosmos-cache's Introduction

Optimize Cosmos query calls with this chain syncronized caching layer.

This program sits on top of another server and acts as a middleware between the requesting client and the actual cosmos RPC/API server.

It supports

  • Variable length cache times (for both RPC methods & REST URL endpoints)

  • Disable specific endpoints entirely from being queried (ex: REST API /accounts)

  • Enable cache only until the next block (via Tendermint RPC event subscription)

  • Cached RPC request

  • Cached REST request

  • Swagger + OpenAPI support (openapi.yml cached)

  • HttpBatchClient (for RPC with Tendermint 0.34 client)

  • Statistics (optional /stats endpoint with password)

  • Websocket basic passthrough support for Keplr wallet

  • Index blocks (TODO?)

Public Endpoints

Juno

Akash

CosmosHub

Comdex

Chihuahua

Injective

Pre-Requirements

  • A Cosmos RPC / REST server endpoint (state synced, full node, or archive).
  • A reverse proxy (to forward subdomain -> the endpoint cache on a machine)

NOTE In the past, Redis was used. If you wish to use Redis still it can be found in v0.0.8

Where to run

Ideally, you should run this on your RPC/REST Node for localhost queries. However, you can also run on other infra including on your reverse proxy itself, or another separate node. This makes it possible to run on cloud providers like Akash, AWS, GCP, Azure, etc.


Setup

python3 -m pip install -r requirements/requirements.txt --upgrade

# Edit the ENV file to your needs
cp configs/.env .env

# Update which endpoints you want to disable / allow (regex) & how long to cache each for.
cp configs/cache_times.json cache_times.json

# THen run to ensure it was setup correctly
python3 rest.py
# ctrl + c
python3 rpc.py
# ctrl + c

# If all is good, continue on.
# NOTE: You can only run 1 of each locally at a time because WSGI is a pain. Requires Systemd as a service to run both in parallel.

# Then point your NGINX / CADDY config to this port rather than the default 26657 / 1317 endpoints

Running in Production

Documentation

cosmos-cache's People

Contributors

reecepbcups avatar charlesjudith 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.