Class: RailsServerMonitor::SidekiqMiddleware

Inherits:
Object
  • Object
show all
Defined in:
app/middlewares/rails_server_monitor/sidekiq_middleware.rb

Instance Method Summary collapse

Instance Method Details

#call(worker, *_) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/middlewares/rails_server_monitor/sidekiq_middleware.rb', line 5

def call(worker, *_)
  return yield if ignore_worker?(worker)

  yield.tap do
    server = RailsServerMonitor::ServerSetup.new.call
    snapshot = RailsServerMonitor::TakeSnapshot.new(server)

    if snapshot.can_take_snapshot?
      snapshot.call

      RailsServerMonitor::Cleanup.new.call
    end
  end
end

#configObject



27
28
29
# File 'app/middlewares/rails_server_monitor/sidekiq_middleware.rb', line 27

def config
  RailsServerMonitor.config
end

#ignore_worker?(worker) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
23
24
25
# File 'app/middlewares/rails_server_monitor/sidekiq_middleware.rb', line 20

def ignore_worker?(worker)
  return false if config.ignore_workers.blank?
  klass_name = worker.class.name

  config.ignore_workers.include?(klass_name)
end