sidekiq-notifications 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +33 -0
- data/Rakefile +7 -0
- data/lib/sidekiq-notifications.rb +1 -0
- data/lib/sidekiq/notifications.rb +20 -0
- data/lib/sidekiq/notifications/client_middleware.rb +15 -0
- data/lib/sidekiq/notifications/server_middleware.rb +13 -0
- data/lib/sidekiq/notifications/version.rb +5 -0
- data/sidekiq-notifications.gemspec +25 -0
- data/spec/sidekiq/notifications/client_middleware_spec.rb +18 -0
- data/spec/sidekiq/notifications/server_middleware_spec.rb +16 -0
- data/spec/sidekiq/notifications_spec.rb +15 -0
- data/spec/spec_helper.rb +8 -0
- metadata +134 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 41685c6396bed4ed353e43cd749e2ec5b9153b49
|
4
|
+
data.tar.gz: baf9ba95c3ef18c610204b279caea5f5167b905a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 890c9c9dd869bce47554bccdb1091af31316eaf4262faeda8ea1994aa7302a46c02d470f6577577b93eac630d8adb75bc951af73e1d042b0a70a47702881e688
|
7
|
+
data.tar.gz: 629b719dd4a4f3bc9d64f85722348e2b34eeb01cdad0e65f789589fb0db3eef23a57d8f9294031b6ed844eed6164daf190967c74034dbf8ddda0e027163dcbe3
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Allen Madsen
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Sidekiq::Notifications
|
2
|
+
|
3
|
+
[](https://circleci.com/gh/lintci/sidekiq-notifications)
|
4
|
+
|
5
|
+
Adds ActiveSupport/Notifications support to sidekiq.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'sidekiq-notifications'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install sidekiq-notifications
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Provides two events to subscribe to: `app.worker.enqueue` and `app.worker.perform` with ActiveSupport::Notifications. The payload contains a `title` like `MyWorker#perform_async` and `MyWorker#perform`. The payload also contains the `job` information directly from sidekiq.
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
1. Fork it ( https://github.com/lintci/sidekiq-notifications/fork )
|
30
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
31
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
32
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
33
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'sidekiq/notifications'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'sidekiq'
|
2
|
+
|
3
|
+
require_relative 'notifications/version'
|
4
|
+
require_relative 'notifications/client_middleware'
|
5
|
+
require_relative 'notifications/server_middleware'
|
6
|
+
|
7
|
+
Sidekiq.configure_client do |config|
|
8
|
+
config.client_middleware do |chain|
|
9
|
+
chain.add Sidekiq::Notifications::ClientMiddleware
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
Sidekiq.configure_server do |config|
|
14
|
+
config.client_middleware do |chain|
|
15
|
+
chain.add Sidekiq::Notifications::ClientMiddleware
|
16
|
+
end
|
17
|
+
config.server_middleware do |chain|
|
18
|
+
chain.add Sidekiq::Notifications::ServerMiddleware
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'active_support/notifications'
|
2
|
+
|
3
|
+
module Sidekiq
|
4
|
+
module Notifications
|
5
|
+
class ClientMiddleware
|
6
|
+
def call(worker_class, job, queue, redis_pool)
|
7
|
+
method = job['at'] ? 'perform_in' : 'perform_async'
|
8
|
+
|
9
|
+
ActiveSupport::Notifications.instrument('app.worker.enqueue', title: "#{worker_class.to_s}##{method}", job: job) do
|
10
|
+
yield
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'active_support/notifications'
|
2
|
+
|
3
|
+
module Sidekiq
|
4
|
+
module Notifications
|
5
|
+
class ServerMiddleware
|
6
|
+
def call(worker, job, queue)
|
7
|
+
ActiveSupport::Notifications.instrument('app.worker.perform', title: "#{worker.class.to_s}#perform", job: job) do
|
8
|
+
yield
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sidekiq/notifications/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "sidekiq-notifications"
|
8
|
+
spec.version = Sidekiq::Notifications::VERSION
|
9
|
+
spec.authors = ["Allen Madsen"]
|
10
|
+
spec.email = ["blatyo@gmail.com"]
|
11
|
+
spec.summary = %q{Adds ActiveSupport/Notifications support to sidekiq.}
|
12
|
+
spec.homepage = "https://github.com/lintci/sidekiq-notifications"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_runtime_dependency 'sidekiq', '>= 3.3.0'
|
21
|
+
spec.add_runtime_dependency 'activesupport', '>= 4.2.0'
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sidekiq::Notifications::ClientMiddleware do
|
4
|
+
subject(:middleware){described_class.new}
|
5
|
+
let(:job){{}}
|
6
|
+
|
7
|
+
FakeWorker = Class.new
|
8
|
+
|
9
|
+
it 'wraps block in skylight instrument' do
|
10
|
+
expect(::ActiveSupport::Notifications).to receive(:instrument).with(
|
11
|
+
'app.worker.enqueue',
|
12
|
+
title: 'FakeWorker#perform_async',
|
13
|
+
job: job
|
14
|
+
){|&block| block.call}
|
15
|
+
|
16
|
+
expect{|probe| middleware.call(FakeWorker, job, double(:queue), double(:redis_pool), &probe)}.to yield_control
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
describe Sidekiq::Notifications::ServerMiddleware do
|
2
|
+
subject(:middleware){described_class.new}
|
3
|
+
let(:job){{}}
|
4
|
+
|
5
|
+
FakeWorker = Class.new
|
6
|
+
|
7
|
+
it 'wraps block in skylight instrument' do
|
8
|
+
expect(::ActiveSupport::Notifications).to receive(:instrument).with(
|
9
|
+
'app.worker.perform',
|
10
|
+
title: 'FakeWorker#perform',
|
11
|
+
job: job
|
12
|
+
){|&block| block.call}
|
13
|
+
|
14
|
+
expect{|probe| middleware.call(FakeWorker.new, job, double(:queue), &probe)}.to yield_control
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sidekiq::Notifications do
|
4
|
+
it 'has a version number' do
|
5
|
+
expect(Sidekiq::Notifications::VERSION).not_to be nil
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'adds Notifications as last server middleware' do
|
9
|
+
expect(Sidekiq.server_middleware.entries.last.klass).to eq(Sidekiq::Notifications::ServerMiddleware)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'adds Notifications as last client middleware' do
|
13
|
+
expect(Sidekiq.client_middleware.entries.last.klass).to eq(Sidekiq::Notifications::ClientMiddleware)
|
14
|
+
end
|
15
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sidekiq-notifications
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Allen Madsen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sidekiq
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.3.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.3.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 4.2.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 4.2.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- blatyo@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- lib/sidekiq-notifications.rb
|
97
|
+
- lib/sidekiq/notifications.rb
|
98
|
+
- lib/sidekiq/notifications/client_middleware.rb
|
99
|
+
- lib/sidekiq/notifications/server_middleware.rb
|
100
|
+
- lib/sidekiq/notifications/version.rb
|
101
|
+
- sidekiq-notifications.gemspec
|
102
|
+
- spec/sidekiq/notifications/client_middleware_spec.rb
|
103
|
+
- spec/sidekiq/notifications/server_middleware_spec.rb
|
104
|
+
- spec/sidekiq/notifications_spec.rb
|
105
|
+
- spec/spec_helper.rb
|
106
|
+
homepage: https://github.com/lintci/sidekiq-notifications
|
107
|
+
licenses:
|
108
|
+
- MIT
|
109
|
+
metadata: {}
|
110
|
+
post_install_message:
|
111
|
+
rdoc_options: []
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubyforge_project:
|
126
|
+
rubygems_version: 2.4.5
|
127
|
+
signing_key:
|
128
|
+
specification_version: 4
|
129
|
+
summary: Adds ActiveSupport/Notifications support to sidekiq.
|
130
|
+
test_files:
|
131
|
+
- spec/sidekiq/notifications/client_middleware_spec.rb
|
132
|
+
- spec/sidekiq/notifications/server_middleware_spec.rb
|
133
|
+
- spec/sidekiq/notifications_spec.rb
|
134
|
+
- spec/spec_helper.rb
|