indexer-manager

module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2021 License: Apache-2.0

README

⚠ This is the new version of manager, if you're looking for the old one you can find it on legacy-manager branch This repository contains an indexer manager for transactions.

Structure

Connectivity

Manager and Worker are linked by GRPC bidirectional streams. To connect with each other, worker needs to know manager's http interface. After initial request is done - GRPC connection is started in another direction - from client to manager. All the following communication between services happen after. For every request, worker should sent a x number of responses marked with request's taskID. Response set should be terminated by one message with status being final.

Activity

Workers are meant to be stateless, this is why the main responsibility of managers is to serve requests from outside. Managers are not creating intermediate states. Every operation done on data is atomic. This allows to run more than one instance of manager in the same time.

Scheduling

To fulfill current goals, system needs to operate on actions that are triggered periodically. Because system may work with multiple instances of manager, this creates an obvious problem of reoccurring activities. This is why scheduler was created as separated process. It allows to connect to multiple managers in the form of SDS-like service. You can find scheduler inside indexer-scheduler repository.

Manager

Process that is responsible for maintaining current state of system

Client

It should not contain any transport related operations such as data conversions of parameter checks. All the input and output structures should be as carrier-agnostic as possible.

Connectivity

Manager's Package for maintaining connections with workers. Currently allows to start the abstract connection with workers, match request with the response and direct that to proper client handles. Also implements simple round robin strategy for sending every next request to another currently connected worker.

Transport
  • GRPC transport for connectivity package. Bidirectional stream implementation for worker connectivity.
  • HTTP transport containing set of user-facing endpoints with non-business logic data validation.

Worker

Stateless worker that is responsible for connecting with the chain, getting information, converting it to a common format and sending it back to manager. Worker can be connected with multiple managers but should always answer only to the one that sent request.

Transport

Currently implemented transport allow worker to run using grpc.

Connectivity

Basic functions for initial simple service discovery. Right now, http queries to every manager triggered periodically.

API

Implementation of bare requests for network.

Client

Worker's business logic wiring of messages to client's functions.

Docker-Compose

This repo also comes with partially preconfigured docker-compose setup. To run using docker-compose you need to

  • Start docker-compose (If you're running that for the first time you may need to run docker swarm init )
    docker-compose build
    docker-compose up

First manager would (the main api) would be available under http://0.0.0.0:8085

Docker-compose version comes also with preconfigured prometheus and grafana, serving content on :3000 and :9090

Compile

To compile sources you need to have go 1.16+ installed. For Worker and Manager it's respectively

    make build 
    make build-manager
Running

The mandatory env variables (or json file) for both manager and migration the parameters are:

    ADDRESS=0.0.0.0:8085

Where ADDRESS is the ip:port string with http interface. It is possible to set the same parameters in json file under --config config.json

After setting up the database you need to run migration script it takes database from DATABASE_URL env var. (migrations are inside cmd/manager-migration/migrations directory)

    migrationn  --path "./path/to/migrations"

Directories

Path Synopsis
cmd
ws
manager
client/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
worker
transport/grpc
Package GRPC incorporate GRPC interface of worker allows it to accept new streams and forward messages
Package GRPC incorporate GRPC interface of worker allows it to accept new streams and forward messages

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL