README.md in sidekiq-throttled-0.10.0 vs README.md in sidekiq-throttled-0.11.0
- old
+ new
@@ -57,9 +57,41 @@
# ...
end
end
```
+### Observer
+
+You can specify an observer that will be called on throttling. To do so pass an
+`:observer` option with callable object:
+
+``` ruby
+class MyWorker
+ include Sidekiq::Worker
+ include Sidekiq::Throttled::Worker
+
+ MY_OBSERVER = lambda do |strategy, *args|
+ # do something
+ end
+
+ sidekiq_options :queue => :my_queue
+
+ sidekiq_throttle({
+ :concurrency => { :limit => 10 },
+ :threshold => { :limit => 100, :period => 1.hour }
+ :observer => MY_OBSERVER
+ })
+
+ def perform(*args)
+ # ...
+ end
+end
+```
+
+Observer will receive `strategy, *args` arguments, where `strategy` is a Symbol
+`:concurrency` or `:threshold`, and `*args` are the arguements that were passed
+to the job.
+
### Dynamic throttling
You can throttle jobs dynamically with `:key_suffix` option: