sidekiq-cron 1.1.0 → 1.2.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: b5929e2b3d41bf1078869e244c7b660ef7579f72
4
- data.tar.gz: a3c65448ccd82839b5be5a28dfc5e03af49c65ea
3
+ metadata.gz: cb2f152cb3faf85dbc089e10820fd48d7c23f6ad
4
+ data.tar.gz: 4ced419b5c9ddaeb43a6ebd62221cdbd95eb2c91
5
5
  SHA512:
6
- metadata.gz: ebe5552febba15ae6bf714c7185ac08de582a4eddd848f9abb7951e8e1385d9db0e9943ac184869d51d65f67d0c2fedf36c153c66d32ca0c742bf652cb2bfb94
7
- data.tar.gz: 9c625373d217af3fe7d62a987a93bd7e01d74ea8c71c1d54a5b8728f7db643da975a4605ffe8ca27685ee9ee612c016ee92b313490b8aaa34e8464bcc90d7e66
6
+ metadata.gz: d882bd7a34f478fc9ea3eb591c6ffe01df2b360ba501ef2df13aa3d7631f77a97a393bc5a391ec682810766dbfe8790bb8a42ed29fc69a666623753103c4c994
7
+ data.tar.gz: 4bbdf927f3830a9a62e2bf622bf34492555e0a8051f303a0a712eda46a818a5dfd78b5de913e137e39b91f046a05247ae2a133cabe1573fa1b4f21307f721b24
@@ -1,10 +1,10 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.6.0
4
- - 2.5.0
5
- - 2.4.3
6
- - 2.3.6
7
- - 2.2.9
3
+ - 2.6
4
+ - 2.5
5
+ - 2.4
6
+ - 2.3
7
+ - 2.2
8
8
  services:
9
9
  - redis-server
10
10
  branches:
@@ -16,7 +16,3 @@ notifications:
16
16
  - ondrej@bartas.cz
17
17
  env:
18
18
  travis: 'yes'
19
- matrix:
20
- allow_failures:
21
- - rvm: jruby-19mode
22
- - rvm: rbx-19mode
data/Changes.md CHANGED
@@ -1,3 +1,21 @@
1
+ v 1.2.0
2
+ -------
3
+
4
+ - updated readme
5
+ - fix problem with Sidekiq::Launcher and requiring it when not needed
6
+ - better patching of Sidekiq::Launcher
7
+ - fixed Dockerfile
8
+
9
+ v 1.1.0
10
+ -------
11
+
12
+ - updated readme
13
+ - fix unit tests - changed argument error when getting invalid cron format
14
+ - when fallbacking old job enqueued time use `Time.parse` šwithout format (so ruby can decide best method to parse it)
15
+ - add option `date_as_argument` which will add to your job arguments on last place `Time.now.to_f` when it was eneuqued
16
+ - add option `description` which will allow you to add notes to your jobs so in web view you can see it
17
+ - fixed translations
18
+
1
19
  v 1.0.4
2
20
  -------
3
21
 
data/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM ruby:2.3.1
1
+ FROM ruby:2.4
2
2
  MAINTAINER Joao Serra <joaopfserra@gmail.com>
3
3
 
4
4
  RUN apt-get update && \
data/README.md CHANGED
@@ -42,7 +42,7 @@ Installation
42
42
 
43
43
  or add to your `Gemfile`
44
44
 
45
- gem "sidekiq-cron", "~> 1.0"
45
+ gem "sidekiq-cron", "~> 1.1"
46
46
 
47
47
 
48
48
  Getting Started
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.2.0
@@ -18,4 +18,6 @@ services:
18
18
  - redis:redis.test
19
19
  depends_on:
20
20
  - common
21
- command: dockerize -wait tcp://redis.test:6379 -timeout 60s rake test
21
+ command: dockerize -wait tcp://redis.test:6379 -timeout 60s bundle exec rake test
22
+ volumes:
23
+ - .:/sidekiq-cron
@@ -1,6 +1,3 @@
1
- # require Sidekiq original launcher
2
- require 'sidekiq/launcher'
3
-
4
1
  # require cron poller
5
2
  require 'sidekiq/cron/poller'
6
3
 
@@ -10,44 +7,41 @@ require 'sidekiq/cron/poller'
10
7
  # we are creating new cron poller instance and
11
8
  # adding start and stop commands to launcher
12
9
  module Sidekiq
13
- class Launcher
14
- # Add cron poller to launcher
15
- attr_reader :cron_poller
16
-
17
- # remember old initialize
18
- alias_method :old_initialize, :initialize
19
-
20
- # add cron poller and execute normal initialize of Sidekiq launcher
21
- def initialize(options)
22
- @cron_poller = Sidekiq::Cron::Poller.new
23
- old_initialize options
24
- end
25
-
26
- # remember old run
27
- alias_method :old_run, :run
28
-
29
- # execute normal run of launcher and run cron poller
30
- def run
31
- old_run
32
- cron_poller.start
33
- end
34
-
35
- # remember old quiet
36
- alias_method :old_quiet, :quiet
37
-
38
- # execute normal quiet of launcher and quiet cron poller
39
- def quiet
40
- cron_poller.terminate
41
- old_quiet
10
+ module Cron
11
+ module Launcher
12
+ # Add cron poller to launcher
13
+ attr_reader :cron_poller
14
+
15
+ # add cron poller and execute normal initialize of Sidekiq launcher
16
+ def initialize(options)
17
+ @cron_poller = Sidekiq::Cron::Poller.new
18
+ super(options)
19
+ end
20
+
21
+ # execute normal run of launcher and run cron poller
22
+ def run
23
+ super
24
+ cron_poller.start
25
+ end
26
+
27
+ # execute normal quiet of launcher and quiet cron poller
28
+ def quiet
29
+ cron_poller.terminate
30
+ super
31
+ end
32
+
33
+ # execute normal stop of launcher and stop cron poller
34
+ def stop
35
+ cron_poller.terminate
36
+ super
37
+ end
42
38
  end
39
+ end
40
+ end
43
41
 
44
- # remember old stop
45
- alias_method :old_stop, :stop
42
+ Sidekiq.configure_server do
43
+ # require Sidekiq original launcher
44
+ require 'sidekiq/launcher'
46
45
 
47
- # execute normal stop of launcher and stop cron poller
48
- def stop
49
- cron_poller.terminate
50
- old_stop
51
- end
52
- end
46
+ ::Sidekiq::Launcher.prepend(Sidekiq::Cron::Launcher)
53
47
  end
@@ -17,8 +17,8 @@ module Sidekiq
17
17
  rescue => ex
18
18
  # Most likely a problem with redis networking.
19
19
  # Punt and try again at the next interval
20
- logger.error ex.message
21
- logger.error ex.backtrace.first
20
+ Sidekiq.logger.error ex.message
21
+ Sidekiq.logger.error ex.backtrace.first
22
22
  handle_exception(ex) if respond_to?(:handle_exception)
23
23
  end
24
24
 
@@ -28,8 +28,8 @@ module Sidekiq
28
28
  job.test_and_enque_for_time! time if job && job.valid?
29
29
  rescue => ex
30
30
  # problem somewhere in one job
31
- logger.error "CRON JOB: #{ex.message}"
32
- logger.error "CRON JOB: #{ex.backtrace.first}"
31
+ Sidekiq.logger.error "CRON JOB: #{ex.message}"
32
+ Sidekiq.logger.error "CRON JOB: #{ex.backtrace.first}"
33
33
  handle_exception(ex) if respond_to?(:handle_exception)
34
34
  end
35
35
 
@@ -25,7 +25,7 @@ module Sidekiq
25
25
  view_path = File.join(File.expand_path("..", __FILE__), "views")
26
26
 
27
27
  @job = Sidekiq::Cron::Job.find(route_params[:name])
28
- if @job.present?
28
+ if @job
29
29
  #if Slim renderer exists and sidekiq has layout.slim in views
30
30
  if defined?(Slim) && File.exists?(File.join(settings.views,"layout.slim"))
31
31
  render(:slim, File.read(File.join(view_path, "cron_show.slim")))
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: sidekiq-cron 1.1.0 ruby lib
5
+ # stub: sidekiq-cron 1.2.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "sidekiq-cron".freeze
9
- s.version = "1.1.0"
9
+ s.version = "1.2.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Ondrej Bartas".freeze]
14
- s.date = "2019-01-16"
14
+ s.date = "2020-04-03"
15
15
  s.description = "Enables to set jobs to be run in specified time (using CRON notation)".freeze
16
16
  s.email = "ondrej@bartas.cz".freeze
17
17
  s.extra_rdoc_files = [
@@ -57,7 +57,7 @@ Gem::Specification.new do |s|
57
57
  ]
58
58
  s.homepage = "http://github.com/ondrejbartas/sidekiq-cron".freeze
59
59
  s.licenses = ["MIT".freeze]
60
- s.rubygems_version = "2.5.2.1".freeze
60
+ s.rubygems_version = "2.5.2.3".freeze
61
61
  s.summary = "Sidekiq Cron helps to add repeated scheduled jobs".freeze
62
62
 
63
63
  if s.respond_to? :specification_version then
@@ -6,9 +6,7 @@ describe 'Performance Poller' do
6
6
  X = 10000
7
7
  before do
8
8
  Sidekiq.redis = REDIS
9
- Sidekiq.redis do |conn|
10
- conn.flushdb
11
- end
9
+ Redis.current.flushdb
12
10
 
13
11
  #clear all previous saved data from redis
14
12
  Sidekiq.redis do |conn|
@@ -33,7 +31,7 @@ describe 'Performance Poller' do
33
31
  Time.stubs(:now).returns(enqueued_time)
34
32
  end
35
33
 
36
- it 'should enqueue 10000 jobs in less than 30s' do
34
+ it 'should enqueue 10000 jobs in less than 40s' do
37
35
  Sidekiq.redis do |conn|
38
36
  assert_equal 0, conn.llen("queue:default"), 'Queue should be empty'
39
37
  end
@@ -47,6 +45,6 @@ describe 'Performance Poller' do
47
45
  end
48
46
 
49
47
  puts "Performance test finished in #{bench.real}"
50
- assert_operator bench.real, :<, 30
48
+ assert_operator bench.real, :<, 40
51
49
  end
52
50
  end
@@ -20,7 +20,7 @@ Coveralls.wear!
20
20
  require "minitest/autorun"
21
21
  require 'shoulda-context'
22
22
  require "rack/test"
23
- require "mocha/setup"
23
+ require 'mocha/minitest'
24
24
 
25
25
  ENV['RACK_ENV'] = 'test'
26
26
 
@@ -5,9 +5,7 @@ require './test/test_helper'
5
5
  describe 'Cron Poller' do
6
6
  before do
7
7
  Sidekiq.redis = REDIS
8
- Sidekiq.redis do |conn|
9
- conn.flushdb
10
- end
8
+ Redis.current.flushdb
11
9
 
12
10
  #clear all previous saved data from redis
13
11
  Sidekiq.redis do |conn|
@@ -9,7 +9,7 @@ describe 'Cron web' do
9
9
 
10
10
  before do
11
11
  Sidekiq.redis = REDIS
12
- Sidekiq.redis {|c| c.flushdb }
12
+ Redis.current.flushdb
13
13
 
14
14
  #clear all previous saved data from redis
15
15
  Sidekiq.redis do |conn|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-cron
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ondrej Bartas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-16 00:00:00.000000000 Z
11
+ date: 2020-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq
@@ -339,7 +339,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
339
339
  version: '0'
340
340
  requirements: []
341
341
  rubyforge_project:
342
- rubygems_version: 2.5.2.1
342
+ rubygems_version: 2.5.2.3
343
343
  signing_key:
344
344
  specification_version: 4
345
345
  summary: Sidekiq Cron helps to add repeated scheduled jobs