Giter VIP home page Giter VIP logo

heal-remote-schema's Introduction

Heal Remote Schemas

A script for auto healing the inconsistent remote schemas in graphql-engine.

Configurable parameters:

This script uses the following configurable parameters (environment variables) for running the auto-healing node server:

Environment variable Required Description Default
GRAPHQL_ENGINE_URL true The url of the graphql engine (e.g. http://localhost:8080) -
HASURA_GRAPHQL_ADMIN_SECRET false The admin secret of the graphql engine. -
CHECK_INTERVAL_SECONDS false The interval for checking the metadata for any inconsistencies (in seconds). 60
RELOAD_INTERVAL_SECONDS false The interval for reloading the remote schemas (in seconds). 60

How does this work?

The checking thread runs the following query to the graphql-engine every CHECK_INTERVAL_SECONDS:

POST v1/metadata
admin

{
  "type": "get_inconsistent_metadata",
  "args": {}
}

If the above query returns any inconsistent remote schema, it stores them in an array.

Now, the reloading thread checks if the inconsistent remote schema array is empty every RELOAD_INTERVAL_SECONDS. If it is empty, then it will just log:

All remote schemas are consistent.

Now, if the array is not empty, then it will try reloading the inconsistent remote schemas:

POST v1/metadata
admin

{
  "type" : "reload_metadata",
  "args": {
    "reload_remote_schemas": *inconsistentSchemas
  }
}

To run this server locally:

Via node

npm install
touch .env
npm start

Via docker

The image is also pushed to docker hub. So you can directly use that in your docker-compose.yaml file or run it separately via docker run.

version: '3.6'
services:
  heal-rs:
    image: hasura/heal-remote-schema
    environment:
      NODE_ENV: production
      GRAPHQL_ENGINE_URL: http://graphql-engine:8080
      HASURA_GRAPHQL_ADMIN_SECRET: hasura
      CHECK_INTERVAL_SECONDS: 10
      RELOAD_INTERVAL_SECONDS: 1
  graphql-engine: ...

heal-remote-schema's People

Contributors

paritosh-08 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.