Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@restorecommerce/chassis-srv

Package Overview
Dependencies
Maintainers
3
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@restorecommerce/chassis-srv

Restore Commerce microservice chassis

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
517
increased by21.65%
Maintainers
3
Weekly downloads
 
Created
Source

chassis-srv

Build StatusDependenciesCoverage Status

A chassis for Restorecommerce microservices.

Features

  • Business logic exposed via gRPC
  • Retry and timeout logic
  • Endpoint calls with custom middleware
  • Provide multiple microservice functionalities from the Restorecommerce ecosystem, such as logging, database access, cache handling or exposing system commands.

Architecture

The chassis consists of 8 components:

  • a configuration loader
  • a multi-transport configurable log infrastructure
  • a base Restorecommerce microservice structure provided by the Server class, which emits state-related events and can be bound to a number of gRPC endpoints, given a Protocol Buffer interface and a transport config
  • custom middleware
  • a cache-loader based on configuration files
  • a provider-based mechanism to access different databases
  • a base implementation for a command-interface
  • periodic storage for Apache Kafka topic offsets

Config

Configs are loaded using the nconf-based module service-config. Such configuration files may contain endpoint specifications along with their associated transports or simple access configs for backing services such as a database or even a Kafka instance.

Logging

Logging functionality is provided through logger, which uses winston. Logger output transport, severity levels and other options are configurable.

Default logging levels are:

  • silly
  • verbose
  • debug
  • info
  • warn
  • error

Server

A Server instance can provide multiple service endpoints and emits events related with the microservice's state. An endpoint is a wrapped gRPC method accessible from any gRPC clients. It is also possible to configure the Server with number of times a request should be retried and timeout configurations. Service responses always include a result or an error. When a Server is instantiated, it is possible to bind one or more services to it, each of them exposing its own RPC endpoints with an associated transport configuration (port, protobuf interfaces, service name, etc). Note that other transport types beside gRPC are theoretically possible, although that would require an extension of the Server class with a custom transport config.

Middleware

Endpoint calls may be intercepted with any number of custom chained middlewares. The request traverses the middleware before reaching the service function. The middleware can call the next middleware until the last middleware calls the service function.

Cache

Multiple cache providers can be registered and loaded within a microservice. Such providers are managed with node-cache-manager.

Database

The following database providers are implemented:

Providers include generic database handling operations (find, insert, upsert delete, truncate, etc). Query parameter structure for all exposed operations is similar with the structure used in MongoDB queries. The ArangoDB provider supports graph database creation and exposes a simple API to manage vertices and edges. It also provides a flexible traversal method. For more details, see graph tests and the ArangoDB graphs documentation. Database providers can be used as a database abstration by any service that owns a set of resources. Furthermore, services can later expose their database operations via gRPC. Exposure of these operations is easily achieved using the resource-base-interface.

Command interface

An interface for system commands (useful information retrieval, system control, etc) is also provided. For more details about all implemented operations please refer command-interface. This interface can be directly exposed as a gRPC endpoint and it can be extended by a microservice for custom functionalities.

Offset Store

This stores the offset values for each Kafka topic within each microservice at a fixed interval to a Redis database. Such intervals are configurable through the offsetStoreInterval configuration value. The offset values are stored with key {kafka:clientId}:{topicName}. In case of a service failure, a microservice can then read the last offset it stored before crashing and thus consume all pending messages since that moment. This feature can be disabled if the latestOffset configuration value is set to true - in this case, the service subscribes to the latest topic offset value upon system restart.

Development

Tests

See tests. To execute the tests a set of backing services are needed. Refer to System repository to start the backing-services before running the tests.

  • To run tests
npm run test

Usage

  • Install dependencies
npm install
  • Build
# compile the code
npm run build

Keywords

FAQs

Package last updated on 29 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc