Created
September 1, 2022 09:39
-
-
Save eguchi-ken/718291e3c986b001a4a5e56cb7244d35 to your computer and use it in GitHub Desktop.
sidekiq のジョブの引数の長さとか調べるやつ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_working_job_argument_size | |
workers = Sidekiq::Workers.new | |
workers.filter_map do |_process_id, _thread_id, work| | |
payload = work.to_a[1] | |
job_class = payload[1]['args'][0]["job_class"] | |
arguments = payload[1]['args'][0]["arguments"] | |
if arguments && arguments.length > 1 | |
result = [job_class] | |
# 引数のうち配列部分だけ長さチェック | |
arguments.each do |argument| | |
if argument.is_a?(Array) | |
result << argument.length | |
end | |
end | |
result | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment