lib/toxiproxy/collection.rb in toxiproxy-0.0.2 vs lib/toxiproxy/collection.rb in toxiproxy-0.1.0

- old
+ new

@@ -26,13 +26,37 @@ # # Toxiproxy.grep(/redis/).down { .. } # # Would simulate every Redis server being down for the duration of the # block. - def down(*args, &block) + def down(&block) @collection.inject(block) { |nested, proxy| - -> { proxy.down(*args, &nested) } + -> { proxy.down(&nested) } }.call + end + + # Set an upstream toxic. + def upstream(toxic, attrs = {}) + toxics = ToxicCollection.new(@collection) + toxics.upstream(toxic, attrs) + toxics + end + + # Set a downstream toxic. + def downstream(toxic, attrs = {}) + toxics = ToxicCollection.new(@collection) + toxics.downstream(toxic, attrs) + toxics + end + + # Disables all proxies in the collection. + def disable + @collection.each(&:disable) + end + + # Enables all proxies in the collection. + def enable + @collection.each(&:enable) end # Destroys all toxiproxy's in the collection def destroy @collection.each(&:destroy)