Travix-International / Hystrix.Dotnet

A combination of circuit breaker and timeout. The .net version of the open source Hystrix library built by Netflix.
https://travix-international.github.io/Hystrix.Dotnet/
MIT License
95 stars 16 forks source link

[Questions] HystrixCommand Design Implementation #18

Closed kolbis closed 6 years ago

kolbis commented 6 years ago

On Netfix java port, you wrap each "critical code" with a command. In other words, you need to create a new class which inherits from HystrixCommand and place your execute and fallback logic inside this class. The approach which was selected for this port differs, so you do not need to create command classes.

  1. Why was this design was prefer?

IMHO, having also the "inheritance" approach is valuable and provides more flexibility and readability (especially for complex behaviors).

  1. What is your take on that? would that something you consider supporting?

My last question refers to production readiness of this port.

  1. Do you have this port already running on large scale production environments?

Thanks!

markvincze commented 6 years ago

Hi @kolbis,

I'm not sure why this design was chosen, I assume it was due to simplicity, so that we don't have to implement a derived type for every command. Maybe that's easier to do in Java thanks to the ability to create anonymous implementations for abstract base classes? @JorritSalverda, can you chime in on this one?

As to your last question: we are running this on production in many APIs, and multiple commands are handling over 100 requests per second.

JorritSalverda commented 6 years ago

I did this mostly because I'm not a big fan of inheritance. I definitely favour composition over inheritance - although that doesn't really apply here as there's little composition going on :) - after having seen so many bad uses of inheritance cornering big software projects into a certain solution without an easy way out.

kolbis commented 6 years ago

Thank you both for the responses. The original implementation of Netflix is using inheritance (and IMHO this makes sense in this case, in order to keep code cleaner).