-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0260a68
commit 2ed0a21
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Encoding: utf-8 | ||
|
||
# This middleware is now a no-op because | ||
# the metriks dependency breaks builds. | ||
|
||
module Qless | ||
module Middleware | ||
module Metriks | ||
|
||
# Tracks the time jobs take, grouping the timings by the job class. | ||
module TimeJobsByClass | ||
def around_perform(job) | ||
super | ||
end | ||
end | ||
|
||
# Increments a counter each time an instance of a particular job class | ||
# completes. | ||
# | ||
# Usage: | ||
# | ||
# Qless::Worker.class_eval do | ||
# include Qless::Middleware::CountEvents.new( | ||
# SomeJobClass => "event_name", | ||
# SomeOtherJobClass => "some_other_event" | ||
# ) | ||
# end | ||
class CountEvents < Module | ||
def initialize(class_to_event_map) | ||
module_eval do # eval the block within the module instance | ||
define_method :around_perform do |job| | ||
super(job) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |