Skip to content

Instantly share code, notes, and snippets.

@jeremylenz
Created November 11, 2020 15:17
Show Gist options
  • Save jeremylenz/80342501550412b3ff881cce279a90e5 to your computer and use it in GitHub Desktop.
Save jeremylenz/80342501550412b3ff881cce279a90e5 to your computer and use it in GitHub Desktop.
methods for tracking dynflow task progress example
module Actions
module Candlepin
module Owner
class UpstreamUpdate < Candlepin::Abstract
input_format do
param :organization_id
param :upstream
end
def run
organization = ::Organization.find(input[:organization_id])
output[:response] = organization.redhat_provider.owner_upstream_update(input[:upstream], {})
output[:progress] = 0
(0...1000).each do |var|
sleep 1
output[:progress] += 1
end
end
# relative weights are used to calculate percent complete based on subtasks done
def run_progress_weight
1_000_000
end
def finalize_progress_weight
42
end
def run_progress
# this is run every time the task is polled
# new instance each time, so won't have access to @instance variables
# however, it does have access to output & input
output[:progress] / 1000
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment