Class: Smplkit::Jobs::Run
- Inherits:
-
Struct
- Object
- Struct
- Smplkit::Jobs::Run
- Defined in:
- lib/smplkit/jobs/models.rb
Overview
A single execution of a job (read-only) with rerun / cancel actions.
Runs are created and mutated by the jobs service, not by clients; clients influence runs only through #rerun / #cancel (and the run action on client.jobs). A run returned from the SDK holds a backref to the runs client so #rerun / #cancel work without re-deriving the client.
Instance Attribute Summary collapse
-
#created_at ⇒ String?
When the run was enqueued (became
PENDING). -
#environment ⇒ String
The environment this run executed in.
-
#error ⇒ String?
Free-text failure detail, if any.
-
#failure_reason ⇒ String?
Why a
FAILEDrun failed;nilotherwise. -
#finished_at ⇒ String?
When execution finished.
-
#id ⇒ String
Server-assigned UUID for this run.
-
#job ⇒ String
The id of the job this run belongs to.
-
#job_version ⇒ Integer?
The job’s version at the time the run executed.
-
#pending_duration_ms ⇒ Integer?
Milliseconds the run waited as
PENDINGbefore starting. -
#request ⇒ Hash?
Snapshot of the request that was sent (header values redacted).
-
#rerun_of ⇒ String?
The source run’s id; set only when
triggerisRERUN. -
#result ⇒ Hash?
Outcome of the call (status, headers, body, …).
-
#run_duration_ms ⇒ Integer?
Milliseconds the run spent executing.
-
#scheduled_for ⇒ String?
The intended fire time for a scheduled run;
nilfor manual / rerun runs. -
#started_at ⇒ String?
When execution started.
-
#status ⇒ String
Lifecycle state of the run.
-
#total_duration_ms ⇒ Integer?
Milliseconds from enqueue to finish.
-
#trigger ⇒ String
Why the run exists — a raw string equal to one of the RunTrigger constants:
SCHEDULE,MANUAL(run now), orRERUN.
Class Method Summary collapse
-
.from_resource(resource, runs: nil) ⇒ Run
The hydrated run.
Instance Method Summary collapse
-
#cancel ⇒ Smplkit::Jobs::Run
Cancel this run if it has not finished yet.
-
#rerun ⇒ Smplkit::Jobs::Run
Start a new run that repeats this one (a
RERUN), in the same environment.
Instance Attribute Details
#created_at ⇒ String?
Returns When the run was enqueued (became PENDING).
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 |
# File 'lib/smplkit/jobs/models.rb', line 723 Run = Struct.new( :id, :job, :job_version, :environment, :trigger, :rerun_of, :scheduled_for, :status, :started_at, :finished_at, :pending_duration_ms, :run_duration_ms, :total_duration_ms, :failure_reason, :error, :request, :result, :created_at, keyword_init: true ) do # @api private — Build a {Run} from a JSON:API resource returned by the # jobs service, binding it to +runs+ so {#rerun} / {#cancel} work. # # @param resource [Object] The JSON:API resource (id + attributes). # @param runs [RunsClient, nil] Runs client to bind the run to. # @return [Run] The hydrated run. def self.from_resource(resource, runs: nil) a = resource.attributes new( id: resource.id, job: a.job, job_version: a.job_version, environment: a.environment, trigger: a.trigger, rerun_of: a.rerun_of, scheduled_for: a.scheduled_for, status: a.status, started_at: a.started_at, finished_at: a.finished_at, pending_duration_ms: a.pending_duration_ms, run_duration_ms: a.run_duration_ms, total_duration_ms: a.total_duration_ms, failure_reason: a.failure_reason, error: a.error, request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request), result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result), created_at: a.created_at ).tap { |run| run.instance_variable_set(:@runs, runs) } end # Start a new run that repeats this one (a +RERUN+), in the same # environment. # # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this # run's id. # @raise [RuntimeError] when this run has no bound runs client. def rerun raise "Run was constructed without a client; cannot rerun" if @runs.nil? @runs.rerun(id) end # Cancel this run if it has not finished yet. # # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation. # @raise [RuntimeError] when this run has no bound runs client. def cancel raise "Run was constructed without a client; cannot cancel" if @runs.nil? @runs.cancel(id) end end |
#environment ⇒ String
Returns The environment this run executed in. A scheduled run inherits the firing job-environment; a manual run uses the environment named on the run-now request; a rerun copies its source run’s environment.
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 |
# File 'lib/smplkit/jobs/models.rb', line 723 Run = Struct.new( :id, :job, :job_version, :environment, :trigger, :rerun_of, :scheduled_for, :status, :started_at, :finished_at, :pending_duration_ms, :run_duration_ms, :total_duration_ms, :failure_reason, :error, :request, :result, :created_at, keyword_init: true ) do # @api private — Build a {Run} from a JSON:API resource returned by the # jobs service, binding it to +runs+ so {#rerun} / {#cancel} work. # # @param resource [Object] The JSON:API resource (id + attributes). # @param runs [RunsClient, nil] Runs client to bind the run to. # @return [Run] The hydrated run. def self.from_resource(resource, runs: nil) a = resource.attributes new( id: resource.id, job: a.job, job_version: a.job_version, environment: a.environment, trigger: a.trigger, rerun_of: a.rerun_of, scheduled_for: a.scheduled_for, status: a.status, started_at: a.started_at, finished_at: a.finished_at, pending_duration_ms: a.pending_duration_ms, run_duration_ms: a.run_duration_ms, total_duration_ms: a.total_duration_ms, failure_reason: a.failure_reason, error: a.error, request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request), result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result), created_at: a.created_at ).tap { |run| run.instance_variable_set(:@runs, runs) } end # Start a new run that repeats this one (a +RERUN+), in the same # environment. # # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this # run's id. # @raise [RuntimeError] when this run has no bound runs client. def rerun raise "Run was constructed without a client; cannot rerun" if @runs.nil? @runs.rerun(id) end # Cancel this run if it has not finished yet. # # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation. # @raise [RuntimeError] when this run has no bound runs client. def cancel raise "Run was constructed without a client; cannot cancel" if @runs.nil? @runs.cancel(id) end end |
#error ⇒ String?
Returns Free-text failure detail, if any.
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 |
# File 'lib/smplkit/jobs/models.rb', line 723 Run = Struct.new( :id, :job, :job_version, :environment, :trigger, :rerun_of, :scheduled_for, :status, :started_at, :finished_at, :pending_duration_ms, :run_duration_ms, :total_duration_ms, :failure_reason, :error, :request, :result, :created_at, keyword_init: true ) do # @api private — Build a {Run} from a JSON:API resource returned by the # jobs service, binding it to +runs+ so {#rerun} / {#cancel} work. # # @param resource [Object] The JSON:API resource (id + attributes). # @param runs [RunsClient, nil] Runs client to bind the run to. # @return [Run] The hydrated run. def self.from_resource(resource, runs: nil) a = resource.attributes new( id: resource.id, job: a.job, job_version: a.job_version, environment: a.environment, trigger: a.trigger, rerun_of: a.rerun_of, scheduled_for: a.scheduled_for, status: a.status, started_at: a.started_at, finished_at: a.finished_at, pending_duration_ms: a.pending_duration_ms, run_duration_ms: a.run_duration_ms, total_duration_ms: a.total_duration_ms, failure_reason: a.failure_reason, error: a.error, request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request), result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result), created_at: a.created_at ).tap { |run| run.instance_variable_set(:@runs, runs) } end # Start a new run that repeats this one (a +RERUN+), in the same # environment. # # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this # run's id. # @raise [RuntimeError] when this run has no bound runs client. def rerun raise "Run was constructed without a client; cannot rerun" if @runs.nil? @runs.rerun(id) end # Cancel this run if it has not finished yet. # # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation. # @raise [RuntimeError] when this run has no bound runs client. def cancel raise "Run was constructed without a client; cannot cancel" if @runs.nil? @runs.cancel(id) end end |
#failure_reason ⇒ String?
Returns Why a FAILED run failed; nil otherwise.
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 |
# File 'lib/smplkit/jobs/models.rb', line 723 Run = Struct.new( :id, :job, :job_version, :environment, :trigger, :rerun_of, :scheduled_for, :status, :started_at, :finished_at, :pending_duration_ms, :run_duration_ms, :total_duration_ms, :failure_reason, :error, :request, :result, :created_at, keyword_init: true ) do # @api private — Build a {Run} from a JSON:API resource returned by the # jobs service, binding it to +runs+ so {#rerun} / {#cancel} work. # # @param resource [Object] The JSON:API resource (id + attributes). # @param runs [RunsClient, nil] Runs client to bind the run to. # @return [Run] The hydrated run. def self.from_resource(resource, runs: nil) a = resource.attributes new( id: resource.id, job: a.job, job_version: a.job_version, environment: a.environment, trigger: a.trigger, rerun_of: a.rerun_of, scheduled_for: a.scheduled_for, status: a.status, started_at: a.started_at, finished_at: a.finished_at, pending_duration_ms: a.pending_duration_ms, run_duration_ms: a.run_duration_ms, total_duration_ms: a.total_duration_ms, failure_reason: a.failure_reason, error: a.error, request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request), result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result), created_at: a.created_at ).tap { |run| run.instance_variable_set(:@runs, runs) } end # Start a new run that repeats this one (a +RERUN+), in the same # environment. # # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this # run's id. # @raise [RuntimeError] when this run has no bound runs client. def rerun raise "Run was constructed without a client; cannot rerun" if @runs.nil? @runs.rerun(id) end # Cancel this run if it has not finished yet. # # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation. # @raise [RuntimeError] when this run has no bound runs client. def cancel raise "Run was constructed without a client; cannot cancel" if @runs.nil? @runs.cancel(id) end end |
#finished_at ⇒ String?
Returns When execution finished.
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 |
# File 'lib/smplkit/jobs/models.rb', line 723 Run = Struct.new( :id, :job, :job_version, :environment, :trigger, :rerun_of, :scheduled_for, :status, :started_at, :finished_at, :pending_duration_ms, :run_duration_ms, :total_duration_ms, :failure_reason, :error, :request, :result, :created_at, keyword_init: true ) do # @api private — Build a {Run} from a JSON:API resource returned by the # jobs service, binding it to +runs+ so {#rerun} / {#cancel} work. # # @param resource [Object] The JSON:API resource (id + attributes). # @param runs [RunsClient, nil] Runs client to bind the run to. # @return [Run] The hydrated run. def self.from_resource(resource, runs: nil) a = resource.attributes new( id: resource.id, job: a.job, job_version: a.job_version, environment: a.environment, trigger: a.trigger, rerun_of: a.rerun_of, scheduled_for: a.scheduled_for, status: a.status, started_at: a.started_at, finished_at: a.finished_at, pending_duration_ms: a.pending_duration_ms, run_duration_ms: a.run_duration_ms, total_duration_ms: a.total_duration_ms, failure_reason: a.failure_reason, error: a.error, request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request), result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result), created_at: a.created_at ).tap { |run| run.instance_variable_set(:@runs, runs) } end # Start a new run that repeats this one (a +RERUN+), in the same # environment. # # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this # run's id. # @raise [RuntimeError] when this run has no bound runs client. def rerun raise "Run was constructed without a client; cannot rerun" if @runs.nil? @runs.rerun(id) end # Cancel this run if it has not finished yet. # # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation. # @raise [RuntimeError] when this run has no bound runs client. def cancel raise "Run was constructed without a client; cannot cancel" if @runs.nil? @runs.cancel(id) end end |
#id ⇒ String
Returns Server-assigned UUID for this run.
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 |
# File 'lib/smplkit/jobs/models.rb', line 723 Run = Struct.new( :id, :job, :job_version, :environment, :trigger, :rerun_of, :scheduled_for, :status, :started_at, :finished_at, :pending_duration_ms, :run_duration_ms, :total_duration_ms, :failure_reason, :error, :request, :result, :created_at, keyword_init: true ) do # @api private — Build a {Run} from a JSON:API resource returned by the # jobs service, binding it to +runs+ so {#rerun} / {#cancel} work. # # @param resource [Object] The JSON:API resource (id + attributes). # @param runs [RunsClient, nil] Runs client to bind the run to. # @return [Run] The hydrated run. def self.from_resource(resource, runs: nil) a = resource.attributes new( id: resource.id, job: a.job, job_version: a.job_version, environment: a.environment, trigger: a.trigger, rerun_of: a.rerun_of, scheduled_for: a.scheduled_for, status: a.status, started_at: a.started_at, finished_at: a.finished_at, pending_duration_ms: a.pending_duration_ms, run_duration_ms: a.run_duration_ms, total_duration_ms: a.total_duration_ms, failure_reason: a.failure_reason, error: a.error, request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request), result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result), created_at: a.created_at ).tap { |run| run.instance_variable_set(:@runs, runs) } end # Start a new run that repeats this one (a +RERUN+), in the same # environment. # # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this # run's id. # @raise [RuntimeError] when this run has no bound runs client. def rerun raise "Run was constructed without a client; cannot rerun" if @runs.nil? @runs.rerun(id) end # Cancel this run if it has not finished yet. # # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation. # @raise [RuntimeError] when this run has no bound runs client. def cancel raise "Run was constructed without a client; cannot cancel" if @runs.nil? @runs.cancel(id) end end |
#job ⇒ String
Returns The id of the job this run belongs to.
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 |
# File 'lib/smplkit/jobs/models.rb', line 723 Run = Struct.new( :id, :job, :job_version, :environment, :trigger, :rerun_of, :scheduled_for, :status, :started_at, :finished_at, :pending_duration_ms, :run_duration_ms, :total_duration_ms, :failure_reason, :error, :request, :result, :created_at, keyword_init: true ) do # @api private — Build a {Run} from a JSON:API resource returned by the # jobs service, binding it to +runs+ so {#rerun} / {#cancel} work. # # @param resource [Object] The JSON:API resource (id + attributes). # @param runs [RunsClient, nil] Runs client to bind the run to. # @return [Run] The hydrated run. def self.from_resource(resource, runs: nil) a = resource.attributes new( id: resource.id, job: a.job, job_version: a.job_version, environment: a.environment, trigger: a.trigger, rerun_of: a.rerun_of, scheduled_for: a.scheduled_for, status: a.status, started_at: a.started_at, finished_at: a.finished_at, pending_duration_ms: a.pending_duration_ms, run_duration_ms: a.run_duration_ms, total_duration_ms: a.total_duration_ms, failure_reason: a.failure_reason, error: a.error, request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request), result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result), created_at: a.created_at ).tap { |run| run.instance_variable_set(:@runs, runs) } end # Start a new run that repeats this one (a +RERUN+), in the same # environment. # # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this # run's id. # @raise [RuntimeError] when this run has no bound runs client. def rerun raise "Run was constructed without a client; cannot rerun" if @runs.nil? @runs.rerun(id) end # Cancel this run if it has not finished yet. # # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation. # @raise [RuntimeError] when this run has no bound runs client. def cancel raise "Run was constructed without a client; cannot cancel" if @runs.nil? @runs.cancel(id) end end |
#job_version ⇒ Integer?
Returns The job’s version at the time the run executed.
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 |
# File 'lib/smplkit/jobs/models.rb', line 723 Run = Struct.new( :id, :job, :job_version, :environment, :trigger, :rerun_of, :scheduled_for, :status, :started_at, :finished_at, :pending_duration_ms, :run_duration_ms, :total_duration_ms, :failure_reason, :error, :request, :result, :created_at, keyword_init: true ) do # @api private — Build a {Run} from a JSON:API resource returned by the # jobs service, binding it to +runs+ so {#rerun} / {#cancel} work. # # @param resource [Object] The JSON:API resource (id + attributes). # @param runs [RunsClient, nil] Runs client to bind the run to. # @return [Run] The hydrated run. def self.from_resource(resource, runs: nil) a = resource.attributes new( id: resource.id, job: a.job, job_version: a.job_version, environment: a.environment, trigger: a.trigger, rerun_of: a.rerun_of, scheduled_for: a.scheduled_for, status: a.status, started_at: a.started_at, finished_at: a.finished_at, pending_duration_ms: a.pending_duration_ms, run_duration_ms: a.run_duration_ms, total_duration_ms: a.total_duration_ms, failure_reason: a.failure_reason, error: a.error, request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request), result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result), created_at: a.created_at ).tap { |run| run.instance_variable_set(:@runs, runs) } end # Start a new run that repeats this one (a +RERUN+), in the same # environment. # # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this # run's id. # @raise [RuntimeError] when this run has no bound runs client. def rerun raise "Run was constructed without a client; cannot rerun" if @runs.nil? @runs.rerun(id) end # Cancel this run if it has not finished yet. # # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation. # @raise [RuntimeError] when this run has no bound runs client. def cancel raise "Run was constructed without a client; cannot cancel" if @runs.nil? @runs.cancel(id) end end |
#pending_duration_ms ⇒ Integer?
Returns Milliseconds the run waited as PENDING before starting.
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 |
# File 'lib/smplkit/jobs/models.rb', line 723 Run = Struct.new( :id, :job, :job_version, :environment, :trigger, :rerun_of, :scheduled_for, :status, :started_at, :finished_at, :pending_duration_ms, :run_duration_ms, :total_duration_ms, :failure_reason, :error, :request, :result, :created_at, keyword_init: true ) do # @api private — Build a {Run} from a JSON:API resource returned by the # jobs service, binding it to +runs+ so {#rerun} / {#cancel} work. # # @param resource [Object] The JSON:API resource (id + attributes). # @param runs [RunsClient, nil] Runs client to bind the run to. # @return [Run] The hydrated run. def self.from_resource(resource, runs: nil) a = resource.attributes new( id: resource.id, job: a.job, job_version: a.job_version, environment: a.environment, trigger: a.trigger, rerun_of: a.rerun_of, scheduled_for: a.scheduled_for, status: a.status, started_at: a.started_at, finished_at: a.finished_at, pending_duration_ms: a.pending_duration_ms, run_duration_ms: a.run_duration_ms, total_duration_ms: a.total_duration_ms, failure_reason: a.failure_reason, error: a.error, request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request), result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result), created_at: a.created_at ).tap { |run| run.instance_variable_set(:@runs, runs) } end # Start a new run that repeats this one (a +RERUN+), in the same # environment. # # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this # run's id. # @raise [RuntimeError] when this run has no bound runs client. def rerun raise "Run was constructed without a client; cannot rerun" if @runs.nil? @runs.rerun(id) end # Cancel this run if it has not finished yet. # # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation. # @raise [RuntimeError] when this run has no bound runs client. def cancel raise "Run was constructed without a client; cannot cancel" if @runs.nil? @runs.cancel(id) end end |
#request ⇒ Hash?
Returns Snapshot of the request that was sent (header values redacted).
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 |
# File 'lib/smplkit/jobs/models.rb', line 723 Run = Struct.new( :id, :job, :job_version, :environment, :trigger, :rerun_of, :scheduled_for, :status, :started_at, :finished_at, :pending_duration_ms, :run_duration_ms, :total_duration_ms, :failure_reason, :error, :request, :result, :created_at, keyword_init: true ) do # @api private — Build a {Run} from a JSON:API resource returned by the # jobs service, binding it to +runs+ so {#rerun} / {#cancel} work. # # @param resource [Object] The JSON:API resource (id + attributes). # @param runs [RunsClient, nil] Runs client to bind the run to. # @return [Run] The hydrated run. def self.from_resource(resource, runs: nil) a = resource.attributes new( id: resource.id, job: a.job, job_version: a.job_version, environment: a.environment, trigger: a.trigger, rerun_of: a.rerun_of, scheduled_for: a.scheduled_for, status: a.status, started_at: a.started_at, finished_at: a.finished_at, pending_duration_ms: a.pending_duration_ms, run_duration_ms: a.run_duration_ms, total_duration_ms: a.total_duration_ms, failure_reason: a.failure_reason, error: a.error, request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request), result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result), created_at: a.created_at ).tap { |run| run.instance_variable_set(:@runs, runs) } end # Start a new run that repeats this one (a +RERUN+), in the same # environment. # # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this # run's id. # @raise [RuntimeError] when this run has no bound runs client. def rerun raise "Run was constructed without a client; cannot rerun" if @runs.nil? @runs.rerun(id) end # Cancel this run if it has not finished yet. # # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation. # @raise [RuntimeError] when this run has no bound runs client. def cancel raise "Run was constructed without a client; cannot cancel" if @runs.nil? @runs.cancel(id) end end |
#rerun_of ⇒ String?
Returns The source run’s id; set only when trigger is RERUN.
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 |
# File 'lib/smplkit/jobs/models.rb', line 723 Run = Struct.new( :id, :job, :job_version, :environment, :trigger, :rerun_of, :scheduled_for, :status, :started_at, :finished_at, :pending_duration_ms, :run_duration_ms, :total_duration_ms, :failure_reason, :error, :request, :result, :created_at, keyword_init: true ) do # @api private — Build a {Run} from a JSON:API resource returned by the # jobs service, binding it to +runs+ so {#rerun} / {#cancel} work. # # @param resource [Object] The JSON:API resource (id + attributes). # @param runs [RunsClient, nil] Runs client to bind the run to. # @return [Run] The hydrated run. def self.from_resource(resource, runs: nil) a = resource.attributes new( id: resource.id, job: a.job, job_version: a.job_version, environment: a.environment, trigger: a.trigger, rerun_of: a.rerun_of, scheduled_for: a.scheduled_for, status: a.status, started_at: a.started_at, finished_at: a.finished_at, pending_duration_ms: a.pending_duration_ms, run_duration_ms: a.run_duration_ms, total_duration_ms: a.total_duration_ms, failure_reason: a.failure_reason, error: a.error, request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request), result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result), created_at: a.created_at ).tap { |run| run.instance_variable_set(:@runs, runs) } end # Start a new run that repeats this one (a +RERUN+), in the same # environment. # # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this # run's id. # @raise [RuntimeError] when this run has no bound runs client. def rerun raise "Run was constructed without a client; cannot rerun" if @runs.nil? @runs.rerun(id) end # Cancel this run if it has not finished yet. # # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation. # @raise [RuntimeError] when this run has no bound runs client. def cancel raise "Run was constructed without a client; cannot cancel" if @runs.nil? @runs.cancel(id) end end |
#result ⇒ Hash?
Returns Outcome of the call (status, headers, body, …).
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 |
# File 'lib/smplkit/jobs/models.rb', line 723 Run = Struct.new( :id, :job, :job_version, :environment, :trigger, :rerun_of, :scheduled_for, :status, :started_at, :finished_at, :pending_duration_ms, :run_duration_ms, :total_duration_ms, :failure_reason, :error, :request, :result, :created_at, keyword_init: true ) do # @api private — Build a {Run} from a JSON:API resource returned by the # jobs service, binding it to +runs+ so {#rerun} / {#cancel} work. # # @param resource [Object] The JSON:API resource (id + attributes). # @param runs [RunsClient, nil] Runs client to bind the run to. # @return [Run] The hydrated run. def self.from_resource(resource, runs: nil) a = resource.attributes new( id: resource.id, job: a.job, job_version: a.job_version, environment: a.environment, trigger: a.trigger, rerun_of: a.rerun_of, scheduled_for: a.scheduled_for, status: a.status, started_at: a.started_at, finished_at: a.finished_at, pending_duration_ms: a.pending_duration_ms, run_duration_ms: a.run_duration_ms, total_duration_ms: a.total_duration_ms, failure_reason: a.failure_reason, error: a.error, request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request), result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result), created_at: a.created_at ).tap { |run| run.instance_variable_set(:@runs, runs) } end # Start a new run that repeats this one (a +RERUN+), in the same # environment. # # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this # run's id. # @raise [RuntimeError] when this run has no bound runs client. def rerun raise "Run was constructed without a client; cannot rerun" if @runs.nil? @runs.rerun(id) end # Cancel this run if it has not finished yet. # # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation. # @raise [RuntimeError] when this run has no bound runs client. def cancel raise "Run was constructed without a client; cannot cancel" if @runs.nil? @runs.cancel(id) end end |
#run_duration_ms ⇒ Integer?
Returns Milliseconds the run spent executing.
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 |
# File 'lib/smplkit/jobs/models.rb', line 723 Run = Struct.new( :id, :job, :job_version, :environment, :trigger, :rerun_of, :scheduled_for, :status, :started_at, :finished_at, :pending_duration_ms, :run_duration_ms, :total_duration_ms, :failure_reason, :error, :request, :result, :created_at, keyword_init: true ) do # @api private — Build a {Run} from a JSON:API resource returned by the # jobs service, binding it to +runs+ so {#rerun} / {#cancel} work. # # @param resource [Object] The JSON:API resource (id + attributes). # @param runs [RunsClient, nil] Runs client to bind the run to. # @return [Run] The hydrated run. def self.from_resource(resource, runs: nil) a = resource.attributes new( id: resource.id, job: a.job, job_version: a.job_version, environment: a.environment, trigger: a.trigger, rerun_of: a.rerun_of, scheduled_for: a.scheduled_for, status: a.status, started_at: a.started_at, finished_at: a.finished_at, pending_duration_ms: a.pending_duration_ms, run_duration_ms: a.run_duration_ms, total_duration_ms: a.total_duration_ms, failure_reason: a.failure_reason, error: a.error, request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request), result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result), created_at: a.created_at ).tap { |run| run.instance_variable_set(:@runs, runs) } end # Start a new run that repeats this one (a +RERUN+), in the same # environment. # # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this # run's id. # @raise [RuntimeError] when this run has no bound runs client. def rerun raise "Run was constructed without a client; cannot rerun" if @runs.nil? @runs.rerun(id) end # Cancel this run if it has not finished yet. # # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation. # @raise [RuntimeError] when this run has no bound runs client. def cancel raise "Run was constructed without a client; cannot cancel" if @runs.nil? @runs.cancel(id) end end |
#scheduled_for ⇒ String?
Returns The intended fire time for a scheduled run; nil for manual / rerun runs.
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 |
# File 'lib/smplkit/jobs/models.rb', line 723 Run = Struct.new( :id, :job, :job_version, :environment, :trigger, :rerun_of, :scheduled_for, :status, :started_at, :finished_at, :pending_duration_ms, :run_duration_ms, :total_duration_ms, :failure_reason, :error, :request, :result, :created_at, keyword_init: true ) do # @api private — Build a {Run} from a JSON:API resource returned by the # jobs service, binding it to +runs+ so {#rerun} / {#cancel} work. # # @param resource [Object] The JSON:API resource (id + attributes). # @param runs [RunsClient, nil] Runs client to bind the run to. # @return [Run] The hydrated run. def self.from_resource(resource, runs: nil) a = resource.attributes new( id: resource.id, job: a.job, job_version: a.job_version, environment: a.environment, trigger: a.trigger, rerun_of: a.rerun_of, scheduled_for: a.scheduled_for, status: a.status, started_at: a.started_at, finished_at: a.finished_at, pending_duration_ms: a.pending_duration_ms, run_duration_ms: a.run_duration_ms, total_duration_ms: a.total_duration_ms, failure_reason: a.failure_reason, error: a.error, request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request), result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result), created_at: a.created_at ).tap { |run| run.instance_variable_set(:@runs, runs) } end # Start a new run that repeats this one (a +RERUN+), in the same # environment. # # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this # run's id. # @raise [RuntimeError] when this run has no bound runs client. def rerun raise "Run was constructed without a client; cannot rerun" if @runs.nil? @runs.rerun(id) end # Cancel this run if it has not finished yet. # # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation. # @raise [RuntimeError] when this run has no bound runs client. def cancel raise "Run was constructed without a client; cannot cancel" if @runs.nil? @runs.cancel(id) end end |
#started_at ⇒ String?
Returns When execution started.
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 |
# File 'lib/smplkit/jobs/models.rb', line 723 Run = Struct.new( :id, :job, :job_version, :environment, :trigger, :rerun_of, :scheduled_for, :status, :started_at, :finished_at, :pending_duration_ms, :run_duration_ms, :total_duration_ms, :failure_reason, :error, :request, :result, :created_at, keyword_init: true ) do # @api private — Build a {Run} from a JSON:API resource returned by the # jobs service, binding it to +runs+ so {#rerun} / {#cancel} work. # # @param resource [Object] The JSON:API resource (id + attributes). # @param runs [RunsClient, nil] Runs client to bind the run to. # @return [Run] The hydrated run. def self.from_resource(resource, runs: nil) a = resource.attributes new( id: resource.id, job: a.job, job_version: a.job_version, environment: a.environment, trigger: a.trigger, rerun_of: a.rerun_of, scheduled_for: a.scheduled_for, status: a.status, started_at: a.started_at, finished_at: a.finished_at, pending_duration_ms: a.pending_duration_ms, run_duration_ms: a.run_duration_ms, total_duration_ms: a.total_duration_ms, failure_reason: a.failure_reason, error: a.error, request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request), result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result), created_at: a.created_at ).tap { |run| run.instance_variable_set(:@runs, runs) } end # Start a new run that repeats this one (a +RERUN+), in the same # environment. # # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this # run's id. # @raise [RuntimeError] when this run has no bound runs client. def rerun raise "Run was constructed without a client; cannot rerun" if @runs.nil? @runs.rerun(id) end # Cancel this run if it has not finished yet. # # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation. # @raise [RuntimeError] when this run has no bound runs client. def cancel raise "Run was constructed without a client; cannot cancel" if @runs.nil? @runs.cancel(id) end end |
#status ⇒ String
Returns Lifecycle state of the run.
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 |
# File 'lib/smplkit/jobs/models.rb', line 723 Run = Struct.new( :id, :job, :job_version, :environment, :trigger, :rerun_of, :scheduled_for, :status, :started_at, :finished_at, :pending_duration_ms, :run_duration_ms, :total_duration_ms, :failure_reason, :error, :request, :result, :created_at, keyword_init: true ) do # @api private — Build a {Run} from a JSON:API resource returned by the # jobs service, binding it to +runs+ so {#rerun} / {#cancel} work. # # @param resource [Object] The JSON:API resource (id + attributes). # @param runs [RunsClient, nil] Runs client to bind the run to. # @return [Run] The hydrated run. def self.from_resource(resource, runs: nil) a = resource.attributes new( id: resource.id, job: a.job, job_version: a.job_version, environment: a.environment, trigger: a.trigger, rerun_of: a.rerun_of, scheduled_for: a.scheduled_for, status: a.status, started_at: a.started_at, finished_at: a.finished_at, pending_duration_ms: a.pending_duration_ms, run_duration_ms: a.run_duration_ms, total_duration_ms: a.total_duration_ms, failure_reason: a.failure_reason, error: a.error, request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request), result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result), created_at: a.created_at ).tap { |run| run.instance_variable_set(:@runs, runs) } end # Start a new run that repeats this one (a +RERUN+), in the same # environment. # # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this # run's id. # @raise [RuntimeError] when this run has no bound runs client. def rerun raise "Run was constructed without a client; cannot rerun" if @runs.nil? @runs.rerun(id) end # Cancel this run if it has not finished yet. # # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation. # @raise [RuntimeError] when this run has no bound runs client. def cancel raise "Run was constructed without a client; cannot cancel" if @runs.nil? @runs.cancel(id) end end |
#total_duration_ms ⇒ Integer?
Returns Milliseconds from enqueue to finish.
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 |
# File 'lib/smplkit/jobs/models.rb', line 723 Run = Struct.new( :id, :job, :job_version, :environment, :trigger, :rerun_of, :scheduled_for, :status, :started_at, :finished_at, :pending_duration_ms, :run_duration_ms, :total_duration_ms, :failure_reason, :error, :request, :result, :created_at, keyword_init: true ) do # @api private — Build a {Run} from a JSON:API resource returned by the # jobs service, binding it to +runs+ so {#rerun} / {#cancel} work. # # @param resource [Object] The JSON:API resource (id + attributes). # @param runs [RunsClient, nil] Runs client to bind the run to. # @return [Run] The hydrated run. def self.from_resource(resource, runs: nil) a = resource.attributes new( id: resource.id, job: a.job, job_version: a.job_version, environment: a.environment, trigger: a.trigger, rerun_of: a.rerun_of, scheduled_for: a.scheduled_for, status: a.status, started_at: a.started_at, finished_at: a.finished_at, pending_duration_ms: a.pending_duration_ms, run_duration_ms: a.run_duration_ms, total_duration_ms: a.total_duration_ms, failure_reason: a.failure_reason, error: a.error, request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request), result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result), created_at: a.created_at ).tap { |run| run.instance_variable_set(:@runs, runs) } end # Start a new run that repeats this one (a +RERUN+), in the same # environment. # # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this # run's id. # @raise [RuntimeError] when this run has no bound runs client. def rerun raise "Run was constructed without a client; cannot rerun" if @runs.nil? @runs.rerun(id) end # Cancel this run if it has not finished yet. # # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation. # @raise [RuntimeError] when this run has no bound runs client. def cancel raise "Run was constructed without a client; cannot cancel" if @runs.nil? @runs.cancel(id) end end |
#trigger ⇒ String
Returns Why the run exists — a raw string equal to one of the Smplkit::Jobs::RunTrigger constants: SCHEDULE, MANUAL (run now), or RERUN.
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 |
# File 'lib/smplkit/jobs/models.rb', line 723 Run = Struct.new( :id, :job, :job_version, :environment, :trigger, :rerun_of, :scheduled_for, :status, :started_at, :finished_at, :pending_duration_ms, :run_duration_ms, :total_duration_ms, :failure_reason, :error, :request, :result, :created_at, keyword_init: true ) do # @api private — Build a {Run} from a JSON:API resource returned by the # jobs service, binding it to +runs+ so {#rerun} / {#cancel} work. # # @param resource [Object] The JSON:API resource (id + attributes). # @param runs [RunsClient, nil] Runs client to bind the run to. # @return [Run] The hydrated run. def self.from_resource(resource, runs: nil) a = resource.attributes new( id: resource.id, job: a.job, job_version: a.job_version, environment: a.environment, trigger: a.trigger, rerun_of: a.rerun_of, scheduled_for: a.scheduled_for, status: a.status, started_at: a.started_at, finished_at: a.finished_at, pending_duration_ms: a.pending_duration_ms, run_duration_ms: a.run_duration_ms, total_duration_ms: a.total_duration_ms, failure_reason: a.failure_reason, error: a.error, request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request), result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result), created_at: a.created_at ).tap { |run| run.instance_variable_set(:@runs, runs) } end # Start a new run that repeats this one (a +RERUN+), in the same # environment. # # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this # run's id. # @raise [RuntimeError] when this run has no bound runs client. def rerun raise "Run was constructed without a client; cannot rerun" if @runs.nil? @runs.rerun(id) end # Cancel this run if it has not finished yet. # # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation. # @raise [RuntimeError] when this run has no bound runs client. def cancel raise "Run was constructed without a client; cannot cancel" if @runs.nil? @runs.cancel(id) end end |
Class Method Details
.from_resource(resource, runs: nil) ⇒ Run
Returns The hydrated run.
735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 |
# File 'lib/smplkit/jobs/models.rb', line 735 def self.from_resource(resource, runs: nil) a = resource.attributes new( id: resource.id, job: a.job, job_version: a.job_version, environment: a.environment, trigger: a.trigger, rerun_of: a.rerun_of, scheduled_for: a.scheduled_for, status: a.status, started_at: a.started_at, finished_at: a.finished_at, pending_duration_ms: a.pending_duration_ms, run_duration_ms: a.run_duration_ms, total_duration_ms: a.total_duration_ms, failure_reason: a.failure_reason, error: a.error, request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request), result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result), created_at: a.created_at ).tap { |run| run.instance_variable_set(:@runs, runs) } end |
Instance Method Details
#cancel ⇒ Smplkit::Jobs::Run
Cancel this run if it has not finished yet.
775 776 777 778 779 |
# File 'lib/smplkit/jobs/models.rb', line 775 def cancel raise "Run was constructed without a client; cannot cancel" if @runs.nil? @runs.cancel(id) end |
#rerun ⇒ Smplkit::Jobs::Run
Start a new run that repeats this one (a RERUN), in the same environment.
765 766 767 768 769 |
# File 'lib/smplkit/jobs/models.rb', line 765 def rerun raise "Run was constructed without a client; cannot rerun" if @runs.nil? @runs.rerun(id) end |