Class: Wurk::Collapse::ClientMiddleware
- Inherits:
-
Object
- Object
- Wurk::Collapse::ClientMiddleware
- Includes:
- JobUtil, Middleware::ClientMiddleware
- Defined in:
- lib/wurk/collapse.rb
Overview
Client middleware — the collapse decision, taken once every other middleware has had the payload.
Prepended, and it decides after its yield. Both halves are load-bearing.
Nothing in the client chain writes to Redis — Wurk::Client#push does that
only once invoke_chain has handed a payload back — so a middleware is
free to run the rest of the chain and then halt the push by returning nil.
Deciding on the way out means the payload Debounce stores in
schedule carries everything the enrichers stamped on it (bid, locale,
cattr, traceparent), so a debounced job really is the scheduled job a
perform_in would have written rather than a stripped-down cousin. Sitting
outermost is what keeps that true for the middleware a host installs later
at boot: Unique.enable!, Encryption.enable! and Telemetry.install!
all add, which appends inside this one.
Constant Summary
Constants included from JobUtil
JobUtil::BOUND_OPTIONS, JobUtil::RETRY_FOR_MAX, JobUtil::TRACK_VALUES, JobUtil::TRANSIENT_ATTRIBUTES
Instance Method Summary collapse
Methods included from JobUtil
#normalize_item, #now_in_millis, positive_seconds?, scheduled_member, #validate, validate_bounds!, validate_track!, #verify_json
Instance Method Details
#call(_worker, job, _queue, redis_pool) ⇒ Object
256 257 258 259 260 261 262 263 264 265 266 |
# File 'lib/wurk/collapse.rb', line 256 def call(_worker, job, _queue, redis_pool) # One Hash lookup for a job that declares nothing, which is every job in # an app that uses neither policy. return yield if job[Wurk::Collapse::OPTION].nil? policy = Wurk::Collapse.policy_for(job) payload = yield return nil if payload.nil? decide(policy, payload, redis_pool) end |