wisper-sidekiq 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 +22 -0
- data/.rspec +2 -0
- data/.travis.yml +10 -0
- data/Gemfile +13 -0
- data/LICENSE.txt +22 -0
- data/README.md +36 -0
- data/Rakefile +2 -0
- data/lib/wisper/sidekiq.rb +21 -0
- data/lib/wisper/sidekiq/version.rb +5 -0
- data/scripts/sidekiq +5 -0
- data/spec/configuration_spec.rb +13 -0
- data/spec/dummy_app/app.rb +3 -0
- data/spec/dummy_app/subscriber.rb +7 -0
- data/spec/integration_spec.rb +37 -0
- data/spec/spec_helper.rb +29 -0
- data/wisper-sidekiq.gemspec +23 -0
- metadata +93 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f0b35c819932228defa3d245462af3130c68e0b1
|
4
|
+
data.tar.gz: d2e23253a221af849da6457a0c94f6611c48556c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9bff0b75ae7ee15e2596c3efc27ac386b7ac5ac62590cf70c24d465d0717ab7cbdcbcfb344763114fc534ed904228ba3fcc73538d592ee40a3c0c377cc0f6626
|
7
|
+
data.tar.gz: 32c654e236dc7ee0c00808ab258c0885f22e9eb99a45db7ae72b230160f96325b5674f3604ed0a722cc6952d9bb8d0a0abcd7760629d946f07305093d9fdcd1e
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Kris Leech
|
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,36 @@
|
|
1
|
+
# Wisper::Sidekiq
|
2
|
+
|
3
|
+
Provides [Wisper](https://github.com/krisleech/wisper) with asynchronous event
|
4
|
+
publishing using [Sidekiq](https://github.com/mperham/sidekiq).
|
5
|
+
|
6
|
+
[](http://badge.fury.io/rb/wisper-sidekiq)
|
7
|
+
[](https://codeclimate.com/github/krisleech/wisper-sidekiq)
|
8
|
+
[](https://travis-ci.org/krisleech/wisper-sidekiq)
|
9
|
+
[](https://coveralls.io/r/krisleech/wisper-sidekiq?branch=master)
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'wisper-sidekiq'
|
15
|
+
```
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
publisher.subscribe(MyListener, async: true)
|
21
|
+
```
|
22
|
+
|
23
|
+
The listener must be a class (or module), not an object. This is because Sidekiq
|
24
|
+
can not reconstruct the state of an object. However a class is easily reconstructed.
|
25
|
+
|
26
|
+
When publshing events the arguments must be simple as they need to be
|
27
|
+
serialized. For example instead of sending an `ActiveRecord` model as an argument
|
28
|
+
use its id instead.
|
29
|
+
|
30
|
+
See the [Sidekiq best practices](https://github.com/mperham/sidekiq/wiki/Best-Practices)
|
31
|
+
for more information.
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
To run sidekiq use `scripts/sidekiq`. This wraps sidekiq in [rerun](https://github.com/alexch/rerun)
|
36
|
+
which will restart sidekiq when `specs/dummy_app` changes.
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'wisper'
|
2
|
+
require 'sidekiq'
|
3
|
+
|
4
|
+
require 'wisper/sidekiq/version'
|
5
|
+
|
6
|
+
module Wisper
|
7
|
+
class SidekiqBroadcaster
|
8
|
+
def broadcast(subscriber, publisher, event, args)
|
9
|
+
subscriber.delay.public_send(event, *args)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.register
|
13
|
+
Wisper.configure do |config|
|
14
|
+
config.broadcaster :sidekiq, SidekiqBroadcaster.new
|
15
|
+
config.broadcaster :async, SidekiqBroadcaster.new
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
Wisper::SidekiqBroadcaster.register
|
data/scripts/sidekiq
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'wisper/sidekiq'
|
2
|
+
|
3
|
+
RSpec.describe 'configuration' do
|
4
|
+
let(:configuration) { Wisper.configuration }
|
5
|
+
|
6
|
+
it 'configures sidekiq as a broadcaster' do
|
7
|
+
expect(configuration.broadcasters).to include :sidekiq
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'configures sidekiq as default async broadcaster' do
|
11
|
+
expect(configuration.broadcasters[:async]).to be_an_instance_of(Wisper::SidekiqBroadcaster)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'wisper/sidekiq'
|
2
|
+
|
3
|
+
require_relative 'dummy_app/app'
|
4
|
+
require 'sidekiq/api'
|
5
|
+
|
6
|
+
RSpec.describe 'integration tests:' do
|
7
|
+
let(:publisher) do
|
8
|
+
Class.new do
|
9
|
+
include Wisper::Publisher
|
10
|
+
|
11
|
+
def run
|
12
|
+
broadcast(:it_happened, 'hello, world')
|
13
|
+
end
|
14
|
+
end.new
|
15
|
+
end
|
16
|
+
|
17
|
+
before do
|
18
|
+
Sidekiq::Queue.new.clear
|
19
|
+
Sidekiq::RetrySet.new.clear
|
20
|
+
File.delete('/tmp/shared') if File.exist?('/tmp/shared')
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'performs event in a different process' do
|
24
|
+
publisher.subscribe(Subscriber, async: Wisper::SidekiqBroadcaster.new)
|
25
|
+
|
26
|
+
publisher.run
|
27
|
+
|
28
|
+
Timeout.timeout(10) do
|
29
|
+
while !File.exist?('/tmp/shared')
|
30
|
+
sleep(0.1)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
shared_content = File.read('/tmp/shared')
|
35
|
+
expect(shared_content).not_to eq "pid: #{Process.pid}\n"
|
36
|
+
end
|
37
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'coveralls'
|
2
|
+
Coveralls.wear!
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
config.expect_with :rspec do |expectations|
|
6
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
7
|
+
end
|
8
|
+
|
9
|
+
config.mock_with :rspec do |mocks|
|
10
|
+
mocks.verify_partial_doubles = true
|
11
|
+
end
|
12
|
+
|
13
|
+
config.filter_run :focus
|
14
|
+
config.run_all_when_everything_filtered = true
|
15
|
+
|
16
|
+
config.disable_monkey_patching!
|
17
|
+
|
18
|
+
config.warnings = true
|
19
|
+
|
20
|
+
if config.files_to_run.one?
|
21
|
+
config.default_formatter = 'doc'
|
22
|
+
end
|
23
|
+
|
24
|
+
config.profile_examples = 10
|
25
|
+
|
26
|
+
config.order = :random
|
27
|
+
|
28
|
+
Kernel.srand config.seed
|
29
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'wisper/sidekiq/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "wisper-sidekiq"
|
8
|
+
spec.version = Wisper::Sidekiq::VERSION
|
9
|
+
spec.authors = ["Kris Leech"]
|
10
|
+
spec.email = ["kris.leech@gmail.com"]
|
11
|
+
spec.summary = 'Async publishing for Wisper using Sidekiq'
|
12
|
+
spec.description = 'Async publishing for Wisper using Sidekiq'
|
13
|
+
spec.homepage = "https://github.com/krisleech/wisper-sidekiq"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'wisper'
|
22
|
+
spec.add_dependency 'sidekiq'
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wisper-sidekiq
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kris Leech
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: wisper
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sidekiq
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Async publishing for Wisper using Sidekiq
|
42
|
+
email:
|
43
|
+
- kris.leech@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- ".rspec"
|
50
|
+
- ".travis.yml"
|
51
|
+
- Gemfile
|
52
|
+
- LICENSE.txt
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- lib/wisper/sidekiq.rb
|
56
|
+
- lib/wisper/sidekiq/version.rb
|
57
|
+
- scripts/sidekiq
|
58
|
+
- spec/configuration_spec.rb
|
59
|
+
- spec/dummy_app/app.rb
|
60
|
+
- spec/dummy_app/subscriber.rb
|
61
|
+
- spec/integration_spec.rb
|
62
|
+
- spec/spec_helper.rb
|
63
|
+
- wisper-sidekiq.gemspec
|
64
|
+
homepage: https://github.com/krisleech/wisper-sidekiq
|
65
|
+
licenses:
|
66
|
+
- MIT
|
67
|
+
metadata: {}
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 2.2.2
|
85
|
+
signing_key:
|
86
|
+
specification_version: 4
|
87
|
+
summary: Async publishing for Wisper using Sidekiq
|
88
|
+
test_files:
|
89
|
+
- spec/configuration_spec.rb
|
90
|
+
- spec/dummy_app/app.rb
|
91
|
+
- spec/dummy_app/subscriber.rb
|
92
|
+
- spec/integration_spec.rb
|
93
|
+
- spec/spec_helper.rb
|