Sha256: b2b80b427316a66a904ebaf7bec8939e450f828f25377a962ad062e7d7b9b61a
Contents?: true
Size: 1.25 KB
Versions: 6
Compression:
Stored size: 1.25 KB
Contents
module Eco module API class Session class BatchJobs < API::Common::Session::BaseSession attr_reader :name def initialize(e, name:) super(e) @name = name reset end def reset @jobs = {} @callbacks = {} end def [](name) @jobs[name] end def exists?(name) @jobs.key?(name) end def new(name, type:, sets:) fatal "Can't create job named '#{name}' because it already exists." if exists?(name) BatchJob.new(enviro, name: name, type: type, sets: sets).tap do |job| @jobs[name] = job @callbacks[job] = Proc.new if block_given? end end def pending? @jobs.keys.any? do |key| @jobs[key].pending? end end def launch(simulate: false) group_status = {} @jobs.each do |name, job| group_status[job] = job_status = job.launch(simulate: simulate) callback = @callbacks[job] callback.call(job, job_status) if callback end return group_status end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems