Class: Conductor::Http::Models::TaskResult

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/conductor/http/models/task_result.rb

Overview

TaskResult model representing the result of task execution

Constant Summary collapse

SWAGGER_TYPES =
{
  workflow_instance_id: 'String',
  task_id: 'String',
  reason_for_incompletion: 'String',
  callback_after_seconds: 'Integer',
  worker_id: 'String',
  status: 'String',
  output_data: 'Hash<String, Object>',
  logs: 'Array<TaskExecLog>',
  external_output_payload_storage_path: 'String',
  sub_workflow_id: 'String',
  extend_lease: 'Boolean'
}.freeze
ATTRIBUTE_MAP =
{
  workflow_instance_id: :workflowInstanceId,
  task_id: :taskId,
  reason_for_incompletion: :reasonForIncompletion,
  callback_after_seconds: :callbackAfterSeconds,
  worker_id: :workerId,
  status: :status,
  output_data: :outputData,
  logs: :logs,
  external_output_payload_storage_path: :externalOutputPayloadStoragePath,
  sub_workflow_id: :subWorkflowId,
  extend_lease: :extendLease
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

attribute_map, deserialize_model, deserialize_value, find_model_class, from_hash, from_json, parse_datetime, swagger_types, #to_h, #to_json

Constructor Details

#initialize(attributes = {}) ⇒ TaskResult

Initialize a new TaskResult

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/conductor/http/models/task_result.rb', line 46

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  self.workflow_instance_id = attributes[:workflow_instance_id] if attributes.key?(:workflow_instance_id)
  self.task_id = attributes[:task_id] if attributes.key?(:task_id)
  self.reason_for_incompletion = attributes[:reason_for_incompletion] if attributes.key?(:reason_for_incompletion)
  self.callback_after_seconds = attributes[:callback_after_seconds] if attributes.key?(:callback_after_seconds)
  self.worker_id = attributes[:worker_id] if attributes.key?(:worker_id)
  self.status = attributes[:status] if attributes.key?(:status)
  self.output_data = attributes[:output_data] || {}
  self.logs = attributes[:logs] || []
  if attributes.key?(:external_output_payload_storage_path)
    self.external_output_payload_storage_path = attributes[:external_output_payload_storage_path]
  end
  self.sub_workflow_id = attributes[:sub_workflow_id] if attributes.key?(:sub_workflow_id)
  self.extend_lease = attributes[:extend_lease] || false
end

Instance Attribute Details

#callback_after_secondsObject

Returns the value of attribute callback_after_seconds.



39
40
41
# File 'lib/conductor/http/models/task_result.rb', line 39

def callback_after_seconds
  @callback_after_seconds
end

#extend_leaseObject

Returns the value of attribute extend_lease.



39
40
41
# File 'lib/conductor/http/models/task_result.rb', line 39

def extend_lease
  @extend_lease
end

#external_output_payload_storage_pathObject

Returns the value of attribute external_output_payload_storage_path.



39
40
41
# File 'lib/conductor/http/models/task_result.rb', line 39

def external_output_payload_storage_path
  @external_output_payload_storage_path
end

#logsObject

Returns the value of attribute logs.



39
40
41
# File 'lib/conductor/http/models/task_result.rb', line 39

def logs
  @logs
end

#output_dataObject

Returns the value of attribute output_data.



39
40
41
# File 'lib/conductor/http/models/task_result.rb', line 39

def output_data
  @output_data
end

#reason_for_incompletionObject

Returns the value of attribute reason_for_incompletion.



39
40
41
# File 'lib/conductor/http/models/task_result.rb', line 39

def reason_for_incompletion
  @reason_for_incompletion
end

#statusObject

Returns the value of attribute status.



39
40
41
# File 'lib/conductor/http/models/task_result.rb', line 39

def status
  @status
end

#sub_workflow_idObject

Returns the value of attribute sub_workflow_id.



39
40
41
# File 'lib/conductor/http/models/task_result.rb', line 39

def sub_workflow_id
  @sub_workflow_id
end

#task_idObject

Returns the value of attribute task_id.



39
40
41
# File 'lib/conductor/http/models/task_result.rb', line 39

def task_id
  @task_id
end

#worker_idObject

Returns the value of attribute worker_id.



39
40
41
# File 'lib/conductor/http/models/task_result.rb', line 39

def worker_id
  @worker_id
end

#workflow_instance_idObject

Returns the value of attribute workflow_instance_id.



39
40
41
# File 'lib/conductor/http/models/task_result.rb', line 39

def workflow_instance_id
  @workflow_instance_id
end

Class Method Details

.completeTaskResult

Create a COMPLETED task result

Returns:



85
86
87
# File 'lib/conductor/http/models/task_result.rb', line 85

def self.complete
  new(status: TaskResultStatus::COMPLETED)
end

.failed(failure_reason = nil) ⇒ TaskResult

Create a FAILED task result

Parameters:

  • failure_reason (String) (defaults to: nil)

    Optional failure reason

Returns:



92
93
94
95
96
# File 'lib/conductor/http/models/task_result.rb', line 92

def self.failed(failure_reason = nil)
  result = new(status: TaskResultStatus::FAILED)
  result.reason_for_incompletion = failure_reason if failure_reason
  result
end

.failed_with_terminal_error(failure_reason = nil) ⇒ TaskResult

Create a FAILED_WITH_TERMINAL_ERROR task result

Parameters:

  • failure_reason (String) (defaults to: nil)

    Optional failure reason

Returns:



107
108
109
110
111
# File 'lib/conductor/http/models/task_result.rb', line 107

def self.failed_with_terminal_error(failure_reason = nil)
  result = new(status: TaskResultStatus::FAILED_WITH_TERMINAL_ERROR)
  result.reason_for_incompletion = failure_reason if failure_reason
  result
end

.in_progressTaskResult

Create an IN_PROGRESS task result

Returns:



100
101
102
# File 'lib/conductor/http/models/task_result.rb', line 100

def self.in_progress
  new(status: TaskResultStatus::IN_PROGRESS)
end

Instance Method Details

#add_output_data(key, value) ⇒ TaskResult

Add a key-value pair to output_data

Parameters:

  • key (String)

    The key

  • value (Object)

    The value

Returns:



68
69
70
71
72
# File 'lib/conductor/http/models/task_result.rb', line 68

def add_output_data(key, value)
  @output_data ||= {}
  @output_data[key] = value
  self
end

#log(log_message) ⇒ TaskResult

Add a log message

Parameters:

  • log_message (String)

    The log message

Returns:



77
78
79
80
81
# File 'lib/conductor/http/models/task_result.rb', line 77

def log(log_message)
  @logs ||= []
  @logs << log_message
  self
end