sidekiq_remove_scheduled 0.0.3 → 1.0.0

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: c6876c1efc70a32353c2c67b31c809d05701f5be
4
- data.tar.gz: 565146a32c03f0f3c187fe3301462f68cbd78b9f
3
+ metadata.gz: fe25b76fd912cd8dfeccdb24cdc8e32a00cc508a
4
+ data.tar.gz: d60e9ba8ed3c36b94c7dab3541be94762c0d9d83
5
5
  SHA512:
6
- metadata.gz: 8a4763d5b799a350311c5f3556015144ea7ee4601c66e70f971160068e78910ebd920cca2a94d7d7ca96a7566498f40164c4038494793bf9b5baa7d3fb937d0b
7
- data.tar.gz: c9c4306c89ac68d52cea574d8623bbe61ea0dd7ec0e3189e8c1bdb03cbc390b557e9f6995bec546c878acae0158bfb5f867c8c12d1f586ee60dbb12176deb882
6
+ metadata.gz: 71c9bf0db7827a54b680fb15464dd020c4a7a5f3ef2f65c90e0e3efd1dfb79988b5b9bfd3e1bf51a9c43148be0421fa72eee508f73a3a97d37b531d24d6b8624
7
+ data.tar.gz: 58882aa6527fe70dc251101222e7e20774c9206890ebfbabb5306b06566fff76e0472e00c405e1cfab76a1402700ad1932146fab55a19b3ac219ba2cabc2dab9
@@ -1,3 +1,9 @@
1
+ #
2
+ # This class require all files and include hooks in sidekiq modules
3
+ #
4
+ # @author [Rohit Jangid]
5
+ #
6
+
1
7
  require 'sidekiq'
2
8
  require 'celluloid'
3
9
  require 'sidekiq/processor'
@@ -1,3 +1,9 @@
1
+ #
2
+ # This module is responsible for extending scheduled/delayed job methods
3
+ # It also define remove_schduled method
4
+ #
5
+ # @author [Rohit Jangid]
6
+ #
1
7
  module SidekiqRemoveScheduled
2
8
  module Hooks
3
9
  module JobHook
@@ -9,6 +15,10 @@ module SidekiqRemoveScheduled
9
15
  perform_in_hook base
10
16
  remove_scheduled_jobs base
11
17
  end
18
+ #
19
+ # This method is responsible for extending perform_in and perform_at method
20
+ # It stores all job ids in redis for easy dequeueing
21
+ #
12
22
  def self.perform_in_hook(base)
13
23
  default_perform_in = base::ClassMethods.instance_method(:perform_in)
14
24
  base::ClassMethods.send :define_method, :perform_in do |interval, *args|
@@ -21,6 +31,11 @@ module SidekiqRemoveScheduled
21
31
  end
22
32
  base::ClassMethods.send :alias_method, :perform_at, :perform_in
23
33
  end
34
+ #
35
+ # This method is responsible for declaring remove_scheduled method
36
+ # It search redis for worker name and arguments, fetch all job ids
37
+ # and remove those jobs from sidekiq queue
38
+ #
24
39
  def self.remove_scheduled_jobs(base)
25
40
  base::ClassMethods.send :define_method, :remove_scheduled do |*args|
26
41
  field = "#{self.to_s}-#{args.to_s}"
@@ -32,8 +47,8 @@ module SidekiqRemoveScheduled
32
47
  begin
33
48
  job = ::SidekiqRemoveScheduled::Redis.client.zscan('schedule', itterator, match: pattern)
34
49
  itterator = job.first.to_i
35
- end until job.last.present? || itterator == 0
36
- ::SidekiqRemoveScheduled::Redis.client.zrem('schedule', job.last.first) if job.last.present?
50
+ end until job.last.count != 0 || itterator == 0
51
+ ::SidekiqRemoveScheduled::Redis.client.zrem('schedule', job.last.first) if job.last.count != 0
37
52
  end
38
53
  ::SidekiqRemoveScheduled::Redis.job_queue.del(field)
39
54
  end
@@ -1,9 +1,18 @@
1
+ #
2
+ # This module is responsible for clearing redis queue after job is done performing
3
+ #
4
+ # @author [Rohit Jangid]
5
+ #
1
6
  module SidekiqRemoveScheduled
2
7
  module Hooks
3
8
  module ProcessHook
4
9
  def self.included(base)
5
10
  execute_job_hook base
6
11
  end
12
+ #
13
+ # This method is responsible for extending execute_job method
14
+ # It search current job in redis queue and remove it from job_queue key
15
+ #
7
16
  def self.execute_job_hook(base)
8
17
  default_execute_job = base.instance_method(:execute_job)
9
18
  base.send :define_method, :execute_job do |worker, args|
@@ -1,3 +1,8 @@
1
+ #
2
+ # This module config the logger and maintain all logging methods
3
+ #
4
+ # @author [rohit]
5
+ #
1
6
  module SidekiqRemoveScheduled
2
7
  module Logger
3
8
  class << self
@@ -1,3 +1,8 @@
1
+ #
2
+ # This module contain all redis configuration and client
3
+ #
4
+ # @author [Rohit Jangid]
5
+ #
1
6
  module SidekiqRemoveScheduled
2
7
  module Redis
3
8
  class << self
@@ -1,6 +1,10 @@
1
1
  require 'sidekiq_remove_scheduled/redis'
2
2
  require 'sidekiq_remove_scheduled/logger'
3
3
  module SidekiqRemoveScheduled
4
+ #
5
+ # This method bind sidekiq_remove_scheduled gem to sidekiq gem
6
+ # extend default methods and provide extra methods
7
+ #
4
8
  def self.bind
5
9
  if SidekiqRemoveScheduled::Redis.client.nil?
6
10
  SidekiqRemoveScheduled::Redis.config
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module SidekiqRemoveScheduled
2
- VERSION = '0.0.3'
2
+ VERSION = '1.0.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq_remove_scheduled
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rohit Jangid
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-23 00:00:00.000000000 Z
11
+ date: 2015-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -52,6 +52,48 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '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
+ - !ruby/object:Gem::Dependency
84
+ name: celluloid
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
55
97
  description: Just call remove_scheduled method and pass the argument to the worker
56
98
  to remove scheduled jobs. No need to store Job Ids
57
99
  email: