tfausak / tfausak.github.io

:memo: Taylor Fausak's blog.
https://taylor.fausak.me
Other
20 stars 5 forks source link

Creating a circuit breaker library #46

Closed tfausak closed 9 years ago

tfausak commented 9 years ago

I helped create Stoplight, which recently went into production. It could be useful to talk about the types of problems it solves and why the existing solutions weren't appropriate.

tfausak commented 9 years ago

Although Stoplight's readme lists some existing solutions, I would like to have a list here.

The readme fails to mention a couple others.

Martin Fowler's original blog post presents a Ruby implementation as well.

tfausak commented 9 years ago

circuit_b

Pros:

Cons:

Example:

require 'circuit_b'

CircuitB.configure do |c|
  c.state_storage = CircuitB::Storage::Memory.new
  c.fuse 'example' 
end

CircuitB('example') { p true }
# true
# => 0
tfausak commented 9 years ago

circuit_breaker

Pros:

Cons:

Example:

require 'circuit_breaker'

class C
  include CircuitBreaker
  def example
    p true
  end
  circuit_method :example
end

C.new.example
# true
# => true
tfausak commented 9 years ago

simple_circuit_breaker

Pros:

Cons:

Example:

require 'simple_circuit_breaker'

SimpleCircuitBreaker.new(3, 10).handle { p true }
# true
# => true
tfausak commented 9 years ago

ya_circuit_breaker

Pros:

Cons:

Example:

require 'circuit_breaker'

CircuitBreaker::Basic.new.execute { p true }
# true
# => nil
tfausak commented 9 years ago

breaker

Pros:

Cons:

Example:

require 'breaker'

Breaker.circuit('example').run { p true }
# true
# => true
tfausak commented 9 years ago

circuitbox

Pros:

Cons:

Example:

require 'circuitbox'

Circuitbox.circuit(:example).run { p true }
# D, [2015-02-03T09:05:04.307606 #1128] DEBUG -- : [CIRCUIT] closed: querying example
# true
# D, [2015-02-03T09:05:04.307920 #1128] DEBUG -- : [CIRCUIT] closed: example querie success
# => true
tfausak commented 9 years ago
Gem Company Developer
breaker - Adam Hawkins
circuit_b - Aleksey Gureiev
circuit_breaker Typesafe Will Sargent
circuitbox Yammer Yann Armand
simple_circuit_breaker SoundCloud Julius Volz
ya_circuit_breaker Wooga Patrick Huesler
tfausak commented 9 years ago
Gem Stars Commits LoC
breaker 12 36 409
circuit_b 3 13 600
circuit_breaker 204 23 563
circuitbox 7 31 1066
simple_circuit_breaker 10 13 173
stoplight 5 299 1881
ya_circuit_breaker 0 25 272
tfausak commented 9 years ago

Now that I have done a (hopefully) objective overview, I'd like to dig in to some more subjective remarks.

tfausak commented 9 years ago
Gem Stars Lines Commits Developer Company
breaker 12 409 36 Adam Hawkins -
circuit_b 3 600 13 Aleksey Gureiev -
circuit_breaker 204 563 23 Will Sargent Typesafe
circuitbox 7 1066 31 Yann Armand Yammer
simple_circuit_breaker 10 173 13 Julius Volz & Tobias Schmidt SoundCloud
stoplight 5 1881 299 Cameron Desautels & Taylor Fausak OrgSync
ya_circuit_breaker 0 272 25 Patrick Huesler Wooga