awolden / brakes

Hystrix compliant Node.js Circuit Breaker Library
MIT License
300 stars 35 forks source link

Update Options #109

Open ttessarolo opened 5 years ago

ttessarolo commented 5 years ago

In my code I need to update options for a brake already instantiated (to be more specific I need to update the timeoutvalue).

I'm using Brakes internals to do that:

brake._masterCircuit._opts = Object.assign( {}, brake._masterCircuit._opts, newOptions );

Could be a nice to have an updateOptions(opts) method attached to brake instance to have the same result without touching internals.

awolden commented 5 years ago

That would be nice. I will flag this as an enhancement that anyone can pickup and PR the library. I'm curious: why do you have to update the timeout on a running circuit?

ttessarolo commented 5 years ago

Is due to the logic of the framework I'm writing. First I instantiate all the gRPC clients using Breaks. The you can specify options for each client.

Thus you have (just an example):

// Instantiate the app and load the gRPC clients
const app = Framework({proto_file: services.proto})

// Define specific gRPC call options
app.remote("Service.method", {cache: true, timeout: 100, fallback: () => "Opss"})

Thus first I create breakes, then I define options.