Giter Club home page Giter Club logo

rlay-schema-registry's Introduction

rlay-schema-registry

Client for registering any rlay schema via redis remotely to improve portability of rlay applications.

Usage

Examples focus on usage with rlay-client-lib which is the most common setup.

We assume

const rlayClient = require('./generated/rlay-client');
const { Client } = require('@rlay/rlay-client-lib');
const Redis = require('ioredis');
const { RlaySchemaRegistry } = require('@rlay/schema-registry');

const rlaySchemaRegistry = new RlaySchemaRegistry({
  db: new Redis(), // connect to redis where registered rlay schema is stored
  namespace: 'my-app' // selecting the right registry
});

Write to registry

(async () => {
  // writing the schema to the redis registry
  await rlaySchemaRegistry.writeSchemaFromClient(rlayClient);
  // writeSchemaFromClient uses the low-level methods
  // .writeSchemaCids and .writeSchemaPayloads under the hood.
})();

Read and update client

const emptyRlayClient = new Client();

(async () => {
  // fetching the schema cids and payloads from the registry
  // and passing it to the empty rlay client
  await rlaySchemaRegistry.writeSchemaFromClient(emptyRlayClient);
  // emptyRlayClient is now indistinguishable from the auto generated rlayClient
  // from the example before.
  // assert.deepEqual(emptyRlayClient, rlayClient); -> would return true
  // writeSchemaFromClient uses the low-level methods
  // .readSchemaCids and .readSchemaPayloads under the hood.
})();

rlay-schema-registry's People

Contributors

michaelhirn avatar

Watchers

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