AmplicaLabs / reconnection-service

A Gateway microservice to reconnect graphs in DSNP/Frequency
https://amplicalabs.github.io/reconnection-service/
Apache License 2.0
2 stars 0 forks source link

Graph Reconnection Service

πŸ“— Table of Contents

πŸ“– Reconnection Service

Reconnection Service provides a way for Providers who are migrating their userbase to DSNP/Frequency to easily handle the graph updates as users opt into the migration.

The service scans the Frequency chain for new delegations for the Provider. It then requests, via a Provider's API, the user's Graph keys and the Provider's graph and proceeds to update the migrated user's graph and the graph of previously migrated users connected to the newly migrated user.

πŸ”­ Arch Maps

The Reconnection Service has one main loop that watches the chain for new blocks. Those blocks are then processed to look for new delegations and completed jobs.

Reconnection Service

Additional Diagrams

(back to top)

πŸ›  Built With

Tech Stack

Framework
Language
Testing Libraries
Linting
Data Store
Request Library
Scheduling
Validation
Environment Configuration
Containerization
API Documentation

Key Features

(back to top)

πŸš€ Live Docs

(back to top)

πŸ’» Getting Started

To get a local copy up and running, follow these steps.

Prerequisites

In order to run this project you need:

Setup

Clone this repository to your desired folder:

Example commands:

  git clone git@github.com:AmplicaLabs/account-service.git
  cd account-service

Environment Variables

Modify any environment variables in the .env file as needed. For docker compose env .env.docker.dev file is used. The complete set of environment variables is documented here, and a sample environment file is provided here.

  1. Copy the template values into the .env files.
    cp env.template .env
    cp env.template .env.docker.dev
  2. Replace template values with values appropriate to your environment.

Install

Install NPM Dependencies:

  npm install

Usage

Note: using docker compose file to start the services. This will start the services in development mode.

In order to run the reconnection-service in development mode without containers, you can use the following commands:

1. Start the Redis server container and the Frequency container. You can view the logs with your Docker setup.

   docker compose up -d redis frequency

2. Once Frequency is up, run the chain setup. This will setup 7000 MSAs on the chain with Graph.

   npm run chain-setup

Note: If you change the env's PROVIDER_ACCOUNT_SEED_PHRASE, you will also need to update PROVIDER_ACCOUNT_SEED_PHRASE in setup/testing/index.ts.

3. Start the mock webhook server. You can view the logs with your Docker setup.

  docker compose up -d webhook

4. Start the Api.

Option 1: In a new terminal window, start the reconnection-service app. Logs will be displayed in the terminal for easy reference.

   npm run start:api:debug

-- or --

Option 2: Run the following command to start the reconnection service container. This will start the reconnection service in development mode.

   docker compose up -d reconnection-service

5. Check the job in BullUI, to monitor job progress based on defined tests.

πŸ“‹ Testing

Run the tests.

   npm run test

This will run the matching *.spec.ts files.

Check e2e test file for more details on the test.

Queue Management

You may also view and manage the application's queue at http://localhost:3000/reconnection-service/queue.

Linting

  npm run lint

Auto-format

  npm run format

Debugging

Using the Debugger with VSCode

  1. Follow step 1 from the Development Environment section above to set up the redis and frequency containers.

  2. Use the debug panel and start the Debug Api (NestJS via ts-node) configuration, if you wish to debug the api.

  3. Set breakpoints in the code and debug your code.

  4. Monitor the service worker jobs in BullUI.

    Any API functions that require an extrinsic to be submitted to the blockchain will be queued here. The queue will manage the amount of capacity this service is allowed to use.

    Reference the Frequency Docs for more information about extrinsics and capacity.

Note: Reference .vscode/launch.json for more details on the debug configurations and apply the concepts to your preferred debugger.

(back to top)

🀝 Contributing

Contributions, issues, and feature requests are welcome!

(back to top)

⭐️ Show your support

If you would like to explore contributing bug fixes or enhancements, issues with the label good-first-issue can be a good place to start.

(back to top)

❓FAQ

(back to top)

πŸ“ License

This project is Apache 2.0 licensed.

(back to top)