Class: HerokuVector::Source::Sidekiq
- Inherits:
-
Object
- Object
- HerokuVector::Source::Sidekiq
- Defined in:
- lib/heroku_vector/source/sidekiq.rb
Instance Method Summary collapse
- #build_redis_client(options = {}) ⇒ Object
- #busy_workers ⇒ Object (also: #sample)
- #configure_sidekiq_client(options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Sidekiq
constructor
A new instance of Sidekiq.
- #sidekiq_processes ⇒ Object
- #unit ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Sidekiq
Returns a new instance of Sidekiq.
8 9 10 |
# File 'lib/heroku_vector/source/sidekiq.rb', line 8 def initialize(={}) configure_sidekiq_client() end |
Instance Method Details
#build_redis_client(options = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/heroku_vector/source/sidekiq.rb', line 19 def build_redis_client(={}) return [:redis] if [:redis] connection = Redis.new({ url: [:redis_url] || HerokuVector.sidekiq_redis_url, timeout: 60 }) namespace = [:redis_namespace] || HerokuVector.sidekiq_redis_namespace if namespace return ::Redis::Namespace.new(namespace, redis: connection) else return connection end end |
#busy_workers ⇒ Object Also known as: sample
39 40 41 |
# File 'lib/heroku_vector/source/sidekiq.rb', line 39 def busy_workers sidekiq_processes.reduce(0) {|i, process| i + process['busy'].to_i } end |
#configure_sidekiq_client(options = {}) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/heroku_vector/source/sidekiq.rb', line 12 def configure_sidekiq_client(={}) ::Sidekiq.configure_client do |config| = { :size => 3, :timeout => 10 } config.redis = ConnectionPool.new() { build_redis_client() } end end |
#sidekiq_processes ⇒ Object
35 36 37 |
# File 'lib/heroku_vector/source/sidekiq.rb', line 35 def sidekiq_processes ::Sidekiq::ProcessSet.new end |
#unit ⇒ Object
44 45 46 |
# File 'lib/heroku_vector/source/sidekiq.rb', line 44 def unit 'busy threads' end |