cogworker 0.3.0 → 0.4.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 +4 -4
- data/lib/cogworker/attempts.rb +1 -1
- data/lib/cogworker/basic_fetch.rb +46 -3
- data/lib/cogworker/config.rb +29 -1
- data/lib/cogworker/heartbeat.rb +38 -4
- data/lib/cogworker/history/storage.rb +2 -2
- data/lib/cogworker/job_util.rb +50 -23
- data/lib/cogworker/launcher.rb +26 -2
- data/lib/cogworker/logging.rb +4 -0
- data/lib/cogworker/lua_script.rb +30 -0
- data/lib/cogworker/manager.rb +27 -4
- data/lib/cogworker/owned_key.rb +2 -2
- data/lib/cogworker/periodic/claim.lua +7 -4
- data/lib/cogworker/periodic/release_middleware.rb +2 -2
- data/lib/cogworker/periodic/running_lock.rb +29 -4
- data/lib/cogworker/periodic/ticker.rb +65 -11
- data/lib/cogworker/processor.rb +161 -49
- data/lib/cogworker/redis_keys.rb +7 -0
- data/lib/cogworker/reliable_fetch/unsupported_error.rb +11 -0
- data/lib/cogworker/reliable_fetch.rb +222 -43
- data/lib/cogworker/scheduled.rb +38 -7
- data/lib/cogworker/status/server_middleware.rb +1 -1
- data/lib/cogworker/swarm.rb +1 -0
- data/lib/cogworker/version.rb +1 -1
- data/lib/cogworker/web/optional_session.rb +32 -0
- data/lib/cogworker/web/routes/jobs.rb +58 -23
- data/lib/cogworker/web.rb +16 -2
- data/lib/cogworker.rb +11 -0
- metadata +4 -1
data/lib/cogworker/web.rb
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'rack'
|
|
4
|
-
require 'rack/session/cookie'
|
|
5
4
|
require 'rack/static'
|
|
6
5
|
require 'securerandom'
|
|
7
6
|
|
|
@@ -105,6 +104,19 @@ module Cogworker
|
|
|
105
104
|
@session_secret ||= ENV.fetch('COGWORKER_SESSION_SECRET') { SecureRandom.hex(32) }
|
|
106
105
|
end
|
|
107
106
|
|
|
107
|
+
# `false` drops the built-in session cookie entirely. It's already
|
|
108
|
+
# skipped automatically whenever the host app provides a session
|
|
109
|
+
# (OptionalSession) or one is added via `Web.use` (a
|
|
110
|
+
# `Rack::Session::*` class — see `build_app`). Default true.
|
|
111
|
+
def builtin_session
|
|
112
|
+
@builtin_session.nil? || @builtin_session
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def builtin_session=(enabled)
|
|
116
|
+
@builtin_session = enabled
|
|
117
|
+
@app = nil
|
|
118
|
+
end
|
|
119
|
+
|
|
108
120
|
def session_secret=(secret)
|
|
109
121
|
@session_secret = secret
|
|
110
122
|
@app = nil
|
|
@@ -247,7 +259,9 @@ module Cogworker
|
|
|
247
259
|
|
|
248
260
|
def build_app
|
|
249
261
|
builder = Rack::Builder.new
|
|
250
|
-
|
|
262
|
+
if builtin_session && middlewares.none? { |mw, _| Cogworker::Web::OptionalSession.session_middleware?(mw) }
|
|
263
|
+
builder.use(Cogworker::Web::OptionalSession, secret: session_secret, key: 'cogworker.session')
|
|
264
|
+
end
|
|
251
265
|
# No `cache_control:` (no `immutable`/long `max-age`): these files
|
|
252
266
|
# are plain, unfingerprinted paths that *do* change — every time
|
|
253
267
|
# a vendored stylesheet/script gets edited, or on any gem upgrade —
|
data/lib/cogworker.rb
CHANGED
|
@@ -83,6 +83,17 @@ module Cogworker
|
|
|
83
83
|
!!@server_process
|
|
84
84
|
end
|
|
85
85
|
|
|
86
|
+
# Called right before every `Process.exit!` (which, unlike `exit`,
|
|
87
|
+
# flushes nothing): a custom `Cogworker.logger` writing to a buffered
|
|
88
|
+
# stdout/stderr would otherwise lose its last lines.
|
|
89
|
+
def flush_output!
|
|
90
|
+
[$stdout, $stderr].each do |io|
|
|
91
|
+
io.flush
|
|
92
|
+
rescue StandardError
|
|
93
|
+
nil
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
86
97
|
def server_process!
|
|
87
98
|
@server_process = true
|
|
88
99
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cogworker
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- vdonec
|
|
@@ -222,6 +222,7 @@ files:
|
|
|
222
222
|
- lib/cogworker/job_util.rb
|
|
223
223
|
- lib/cogworker/launcher.rb
|
|
224
224
|
- lib/cogworker/logging.rb
|
|
225
|
+
- lib/cogworker/lua_script.rb
|
|
225
226
|
- lib/cogworker/manager.rb
|
|
226
227
|
- lib/cogworker/middleware/chain.rb
|
|
227
228
|
- lib/cogworker/owned_key.rb
|
|
@@ -239,6 +240,7 @@ files:
|
|
|
239
240
|
- lib/cogworker/redis_connection.rb
|
|
240
241
|
- lib/cogworker/redis_keys.rb
|
|
241
242
|
- lib/cogworker/reliable_fetch.rb
|
|
243
|
+
- lib/cogworker/reliable_fetch/unsupported_error.rb
|
|
242
244
|
- lib/cogworker/scheduled.rb
|
|
243
245
|
- lib/cogworker/signals.rb
|
|
244
246
|
- lib/cogworker/stats.rb
|
|
@@ -269,6 +271,7 @@ files:
|
|
|
269
271
|
- lib/cogworker/web/assets/phosphor/style.css
|
|
270
272
|
- lib/cogworker/web/history_query.rb
|
|
271
273
|
- lib/cogworker/web/layout.rb
|
|
274
|
+
- lib/cogworker/web/optional_session.rb
|
|
272
275
|
- lib/cogworker/web/router.rb
|
|
273
276
|
- lib/cogworker/web/routes/history.rb
|
|
274
277
|
- lib/cogworker/web/routes/jobs.rb
|