Class: Wurk::Encryption::ClientMiddleware
- Inherits:
-
Object
- Object
- Wurk::Encryption::ClientMiddleware
- Includes:
- Middleware::ClientMiddleware
- Defined in:
- lib/wurk/encryption.rb
Overview
Client middleware — envelopes the last positional argument when the job opts in via ‘sidekiq_options encrypt: true`. Skips silently when crypto is disabled, the job didn’t opt in, or ‘args` is empty (per §4.3, an opt-in worker with empty args is a user bug, but we don’t enqueue garbage — let perform raise ArgumentError if it cares).
Instance Method Summary collapse
Instance Method Details
#call(_worker, job, _queue, _redis_pool) ⇒ Object
226 227 228 229 230 231 232 233 234 |
# File 'lib/wurk/encryption.rb', line 226 def call(_worker, job, _queue, _redis_pool) return yield unless Wurk::Encryption.enabled? && job['encrypt'] args = job['args'] if args.is_a?(::Array) && !args.empty? && !Wurk::Encryption.envelope?(args.last) job['args'] = args[0..-2] + [Wurk::Encryption.encrypt(args.last)] end yield end |