BerandaComputers and TechnologyCircuit breaker for gRPC using hystrixjs

Circuit breaker for gRPC using hystrixjs

Codacy Badge

Uses Hystrixjs to provide the Circuit Breaker functionalities to gRPC requests.

Usage

const messages = require('your-protobuf-messages');
const rpcClient = require('your-grpc-client');
const {
  createRpcCommand,
} = require('grpc-circuitbreaker');


// Let's say rpcClient.get(request, (err, res) ...) is your function
// You need really need .bind()!
const command = createRpcCommand(rpcClient.get.bind(rpcClient));
const request = new messages.YourMessage();


command.execute(request).then((response) => {
    // do something with response
  }).catch((error) => {
    // do something with error
  });
};

Tests

No tests YET, was in a hurry when I put this here, sorry.

Read More

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments