sidekiq_runner 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d517ca834f51f234940d98552baf2b1350c53dc0
4
- data.tar.gz: 170e4d46e50f4fb318501c79e99b06714b3e4a07
3
+ metadata.gz: 70dae3500bd9918ade22bab57251a402aae32d65
4
+ data.tar.gz: f2e1d424cdbbd8d11480e75b08893a88d0d96524
5
5
  SHA512:
6
- metadata.gz: 155dc34aa25f16f1382e1db1cc9b19eee507b28ea1316dc66051d1ee0bf8d574cb2bf359acc138233fcbcc5ae88d21824ef5c7fef1c8e22da3b437dbd74249ef
7
- data.tar.gz: 61d5f24d5cbddc8b6a8f5ef740f2c44cb3733e8841fa92a70f95e166f529b3f29fc2102921170775d8eb305462f4578dbdb97afbf5c0908ac72c056f82645e14
6
+ metadata.gz: b6e27df0ab38c8ca378756d24f05da4a60956fc7a772c13f5d9d5406794acb3e4f1ec70a2387dc5cb5de756d18d8208f3692320aa5424eda6fdffb64972fbc03
7
+ data.tar.gz: ae57fc3557a77fe704cd173ab43b0a5bce5af7d597c522ab30fef8b0ec6ff24ad42bd139124f76aa29942fcdab55b086566118b9fd36e94d8bb5dcbcb897e35e
data/README.md CHANGED
@@ -5,7 +5,7 @@ This gem provides easily run multiple methods per sidekiq worker
5
5
  ## Installing
6
6
 
7
7
  ```ruby
8
- gem 'sidekiq-runner'
8
+ gem 'sidekiq_runner'
9
9
  ```
10
10
 
11
11
  ### Example
@@ -13,7 +13,10 @@ gem 'sidekiq-runner'
13
13
  # Your worker
14
14
  class UrlShortenerWorker
15
15
  include Sidekiq::Worker
16
+
16
17
  sidekiq_options backtrace: true, queue: 'url_shortener', retry: 2
18
+
19
+ include SidekiqRunner::SidekiqPerform
17
20
 
18
21
  def create_from_google(params)
19
22
  # id = params[:id]
@@ -37,25 +40,25 @@ end
37
40
  Run `create_from_google` method
38
41
 
39
42
  ```ruby
40
- SidekiqRunner::Run.enqueue('UrlShortenerWorker', 'create_from_google', { id: 1, my_other_arg: 2 })
43
+ SidekiqRunner::Runner.enqueue('UrlShortenerWorker', 'create_from_google', { id: 1, my_other_arg: 2 })
41
44
  # or
42
- SidekiqRunner::Run.run('UrlShortenerWorker', 'create_from_google', { id: 1, my_other_arg: 2 })
45
+ SidekiqRunner::Runner.run('UrlShortenerWorker', 'create_from_google', { id: 1, my_other_arg: 2 })
43
46
  ```
44
47
 
45
48
  Run `create_from_bitly` method
46
49
 
47
50
  ```ruby
48
- SidekiqRunner::Run.enqueue('UrlShortenerWorker', 'create_from_bitly', { id: 1, my_other_arg: 2 })
51
+ SidekiqRunner::Runner.enqueue('UrlShortenerWorker', 'create_from_bitly', { id: 1, my_other_arg: 2 })
49
52
  # or
50
- SidekiqRunner::Run.run('UrlShortenerWorker', 'create_from_bitly', { id: 1, my_other_arg: 2 })
53
+ SidekiqRunner::Runner.run('UrlShortenerWorker', 'create_from_bitly', { id: 1, my_other_arg: 2 })
51
54
  ```
52
55
 
53
56
  Run `my_other_method` method
54
57
 
55
58
  ```ruby
56
- SidekiqRunner::Run.enqueue('UrlShortenerWorker', 'create_from_bitly')
59
+ SidekiqRunner::Runner.enqueue('UrlShortenerWorker', 'my_other_method')
57
60
  # or
58
- SidekiqRunner::Run.run('UrlShortenerWorker', 'create_from_bitly')
61
+ SidekiqRunner::Runner.run('UrlShortenerWorker', 'my_other_method')
59
62
  ```
60
63
 
61
64
  #### NOTE
@@ -0,0 +1,36 @@
1
+ module SidekiqRunner
2
+ module SidekiqPerform
3
+ extend ActiveSupport::Concern
4
+
5
+ module ClassMethods
6
+ def method_missing(method_sym, *args)
7
+ method_name = method_sym.to_s
8
+ if method_name.end_with? '_async'
9
+ queue = sidekiq_options_hash['queue']
10
+ Sidekiq::Client.enqueue_to(queue, self, method_name, args)
11
+ else
12
+ super
13
+ end
14
+ end
15
+ end
16
+
17
+
18
+ def perform(method_name, args)
19
+ method(method_name).call(args)
20
+ end
21
+
22
+ def perform_safe(method_name, args)
23
+ unless File.directory?(Rails.root)
24
+ fail 'Non exist Workers app folder. The release folder deleted. Please retry the job'
25
+ # Please kill the workers and start again. Please check https://www.pivotaltracker.com/story/show/55338376 for more information'
26
+ end
27
+
28
+ if method_name && respond_to?(method_name)
29
+ logger_info("Starting work for #{self.class}.#{method_name}")
30
+ method(method_name).call(args)
31
+ else
32
+ fail "Method #{method_name} doesnt exists in class #{self.class.name.to_s}. No job is performed"
33
+ end
34
+ end
35
+ end
36
+ end
@@ -1,3 +1,3 @@
1
1
  module SidekiqRunner
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -1,4 +1,5 @@
1
1
  require 'sidekiq_runner/runner'
2
+ require 'sidekiq_runner/sidekiq_perform'
2
3
  module SidekiqRunner
3
4
 
4
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq_runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Muhammet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-21 00:00:00.000000000 Z
11
+ date: 2016-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: sidekiq
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '4'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '4'
41
41
  description: Easily run multiple methods per sidekiq worker
42
42
  email:
43
43
  - dilekmuhammet@gmail.com
@@ -50,6 +50,7 @@ files:
50
50
  - Rakefile
51
51
  - lib/sidekiq_runner.rb
52
52
  - lib/sidekiq_runner/runner.rb
53
+ - lib/sidekiq_runner/sidekiq_perform.rb
53
54
  - lib/sidekiq_runner/version.rb
54
55
  - lib/tasks/sidekiq_runner_tasks.rake
55
56
  homepage: https://github.com/movielala/sidekiq_runner