Sha256: 018a7e194ff5d2ffb1613d3829e122be7fb3d69c6dda6f3d07f5d1ea13d4480e
Contents?: true
Size: 1.47 KB
Versions: 4
Compression:
Stored size: 1.47 KB
Contents
# frozen_string_literal: true module Sidekiq module WebCustom class WebApp MAPPED_TYPE = { retries: RetrySet, scheduled: ScheduledSet, } def self.registered(app) app.post '/queues/drain/:name' do timeout_params = { warn: Sidekiq::WebCustom.config.warn_execution_time, timeout: Sidekiq::WebCustom.config.max_execution_time, proc: ->(thread, seconds) { thread[Sidekiq::WebCustom::BREAK_BIT] = 1; Sidekiq.logger.warn "set bit #{thread[Sidekiq::WebCustom::BREAK_BIT]}" } } Thread.current[Sidekiq::WebCustom::BREAK_BIT] = nil Sidekiq::WebCustom::Timeout.timeout(timeout_params) do Sidekiq::Queue.new(params[:name]).drain(max: Sidekiq::WebCustom.config.drain_rate) end redirect_with_query("#{root_path}queues") end app.post '/job/delete' do parsed = parse_params(params['entry.score']) klass = MAPPED_TYPE[params['entry.type'].to_sym] job = klass.new.fetch(*parsed)&.first job&.delete redirect_with_query("#{root_path}scheduled") end app.post '/job/execute' do parsed = parse_params(params['entry.score']) klass = MAPPED_TYPE[params['entry.type'].to_sym] job = klass.new.fetch(*parsed)&.first status = job&.execute redirect_with_query("#{root_path}#{params['entry.type']}") end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems