mini_scheduler 0.8.3 → 0.9.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
  SHA256:
3
- metadata.gz: a5797dd2e9799cede45d53aa7fd2fb2d9f78cde7afeccdc8bc87d8b32475d0cd
4
- data.tar.gz: 58e760af7681a6c33091fe885ac40e2815575e4c8c8512b2e583511875d19a66
3
+ metadata.gz: bf8e76b54130cca4fcd19911dd1b5a9a555c9d4eb082831a3232e8545e4a4fca
4
+ data.tar.gz: b5ae3324219df3967402751423ea3eac9639a111dc121a84acbd5dfdced0bd88
5
5
  SHA512:
6
- metadata.gz: a3c1f7897d11ca24dc8a101633acf76d654460f64e9ca6b67b7ab37dd8eef35b69fece273b7c86ffee00aa0d28849191a5df233dc0e9d61788ee630cd1827004
7
- data.tar.gz: e5f347f7ea57c941805de5190cc30e13596d0e13a2bc60a64ba9cc654114c6a840a747e66b28c5fed0b1a5397999da7402e0e301b4a388cfa90c44e02ca22ada
6
+ metadata.gz: f4c366bd7d125b5d8e8ae267ddeff8eb4499fb86500ca3c6e69984b1659948c730cf859ef69565067ba9e88f0aec2a1c070bdd3477a32de7c95501628312da21
7
+ data.tar.gz: 1d218ff79a0ae03bc46b3af397e074cc1c9198249676c1364d10b2b690cb0a33d74d49f043cdbb8686494a8b91ed402dd4fbe33e921df0a3bdb9b7012d5c0390
data/.gitignore CHANGED
@@ -9,3 +9,5 @@
9
9
  Gemfile.lock
10
10
  .DS_Store
11
11
  *.swp
12
+
13
+ .rubocop-https---raw-githubusercontent-com-discourse-discourse-master--rubocop-yml
data/.rubocop.yml CHANGED
@@ -1,113 +1 @@
1
- AllCops:
2
- TargetRubyVersion: 2.4
3
- DisabledByDefault: true
4
- Exclude:
5
- - 'db/schema.rb'
6
- - 'bundle/**/*'
7
- - 'vendor/**/*'
8
- - 'node_modules/**/*'
9
- - 'public/**/*'
10
-
11
- # Prefer &&/|| over and/or.
12
- Style/AndOr:
13
- Enabled: true
14
-
15
- # Do not use braces for hash literals when they are the last argument of a
16
- # method call.
17
- Style/BracesAroundHashParameters:
18
- Enabled: true
19
-
20
- # Align `when` with `case`.
21
- Layout/CaseIndentation:
22
- Enabled: true
23
-
24
- # Align comments with method definitions.
25
- Layout/CommentIndentation:
26
- Enabled: true
27
-
28
- # No extra empty lines.
29
- Layout/EmptyLines:
30
- Enabled: true
31
-
32
- # Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
33
- Style/HashSyntax:
34
- Enabled: true
35
-
36
- # Two spaces, no tabs (for indentation).
37
- Layout/IndentationWidth:
38
- Enabled: true
39
-
40
- Layout/SpaceAfterColon:
41
- Enabled: true
42
-
43
- Layout/SpaceAfterComma:
44
- Enabled: true
45
-
46
- Layout/SpaceAroundEqualsInParameterDefault:
47
- Enabled: true
48
-
49
- Layout/SpaceAroundKeyword:
50
- Enabled: true
51
-
52
- Layout/SpaceAroundOperators:
53
- Enabled: true
54
-
55
- Layout/SpaceBeforeFirstArg:
56
- Enabled: true
57
-
58
- # Defining a method with parameters needs parentheses.
59
- Style/MethodDefParentheses:
60
- Enabled: true
61
-
62
- # Use `foo {}` not `foo{}`.
63
- Layout/SpaceBeforeBlockBraces:
64
- Enabled: true
65
-
66
- # Use `foo { bar }` not `foo {bar}`.
67
- Layout/SpaceInsideBlockBraces:
68
- Enabled: true
69
-
70
- # Use `{ a: 1 }` not `{a:1}`.
71
- Layout/SpaceInsideHashLiteralBraces:
72
- Enabled: true
73
-
74
- Layout/SpaceInsideParens:
75
- Enabled: true
76
-
77
- # Detect hard tabs, no hard tabs.
78
- Layout/Tab:
79
- Enabled: true
80
-
81
- # Blank lines should not have any spaces.
82
- Layout/TrailingBlankLines:
83
- Enabled: true
84
-
85
- # No trailing whitespace.
86
- Layout/TrailingWhitespace:
87
- Enabled: true
88
-
89
- Lint/Debugger:
90
- Enabled: true
91
-
92
- Lint/BlockAlignment:
93
- Enabled: true
94
-
95
- # Align `end` with the matching keyword or starting expression except for
96
- # assignments, where it should be aligned with the LHS.
97
- Lint/EndAlignment:
98
- Enabled: true
99
- EnforcedStyleAlignWith: variable
100
-
101
- # Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
102
- Lint/RequireParentheses:
103
- Enabled: true
104
-
105
- Layout/MultilineMethodCallIndentation:
106
- Enabled: true
107
- EnforcedStyle: indented
108
-
109
- Layout/AlignHash:
110
- Enabled: true
111
-
112
- Bundler/OrderedGems:
113
- Enabled: false
1
+ inherit_from: https://raw.githubusercontent.com/discourse/discourse/master/.rubocop.yml
@@ -19,6 +19,14 @@ MiniScheduler.configure do |config|
19
19
  # ...
20
20
  # end
21
21
 
22
+ # Before each tick, the configured block is run to check if the next job
23
+ # should be scheduled. The block should return a boolean where a return value
24
+ # of `True` skip scheduling.
25
+
26
+ # config.skip_schedule do
27
+ # ...
28
+ # end
29
+
22
30
  # Add code that runs before processing requests to the
23
31
  # scheduler pages of the Sidekiq web UI.
24
32
 
@@ -29,10 +37,6 @@ end
29
37
 
30
38
  if Sidekiq.server? && defined?(Rails)
31
39
  Rails.application.config.after_initialize do
32
- scheduler_hostname = ENV["UNICORN_SCHEDULER_HOSTNAME"]
33
-
34
- if !scheduler_hostname || scheduler_hostname.split(',').include?(`hostname`.strip)
35
- MiniScheduler.start
36
- end
40
+ MiniScheduler.start
37
41
  end
38
42
  end
@@ -47,22 +47,31 @@ module MiniScheduler
47
47
  @before_sidekiq_web_request
48
48
  end
49
49
 
50
+ def self.skip_schedule(&blk)
51
+ @skip_schedule = blk if blk
52
+ @skip_schedule
53
+ end
54
+
50
55
  def self.start
51
56
  manager = Manager.new
57
+
52
58
  Manager.discover_schedules.each do |schedule|
53
59
  manager.ensure_schedule!(schedule)
54
60
  end
61
+
55
62
  Thread.new do
56
63
  while true
57
64
  begin
58
- manager.tick
65
+ if !self.skip_schedule || !self.skip_schedule.call
66
+ manager.tick
67
+ end
59
68
  rescue => e
60
69
  # the show must go on
61
70
  handle_job_exception(e, message: "While ticking scheduling manager")
62
71
  end
72
+
63
73
  sleep 1
64
74
  end
65
75
  end
66
76
  end
67
-
68
77
  end
@@ -1,3 +1,3 @@
1
1
  module MiniScheduler
2
- VERSION = "0.8.3"
2
+ VERSION = "0.9.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_scheduler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-08-30 00:00:00.000000000 Z
12
+ date: 2019-01-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pg