Class: Temporalio::Client::ActivityExecution::Description

Inherits:
ActivityExecution
  • Object
show all
Defined in:
lib/temporalio/client/activity_execution.rb

Overview

Rich description of a standalone activity execution; returned by Temporalio::Client::ActivityHandle#describe.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#raw_description ⇒ Api::WorkflowService::V1::DescribeActivityExecutionResponse (readonly)

Returns Underlying protobuf response.

Returns:



81
82
83
# File 'lib/temporalio/client/activity_execution.rb', line 81

def raw_description
  @raw_description
end

Instance Method Details

#attempt ⇒ Integer

Returns Current attempt number. Attempts start at 1 and increment on each retry.

Returns:

  • (Integer) —

    Current attempt number. Attempts start at 1 and increment on each retry.



207
208
209
# File 'lib/temporalio/client/activity_execution.rb', line 207

def attempt
  @raw_info.attempt
end

#canceled_reason ⇒ String?

Returns Reason given when cancellation was requested.

Returns:

  • (String, nil) —

    Reason given when cancellation was requested.



274
275
276
# File 'lib/temporalio/client/activity_execution.rb', line 274

def canceled_reason
  Internal::ProtoUtils.string_or(@raw_info.canceled_reason, nil)
end

#current_retry_interval ⇒ Float?

Returns Time from last attempt failure to next retry, in seconds.

Returns:

  • (Float, nil) —

    Time from last attempt failure to next retry, in seconds.



243
244
245
# File 'lib/temporalio/client/activity_execution.rb', line 243

def current_retry_interval
  Internal::ProtoUtils.duration_to_seconds(@raw_info.current_retry_interval)
end

#expiration_time ⇒ Time?

Returns Schedule time + schedule-to-close timeout.

Returns:

  • (Time, nil) —

    Schedule time + schedule-to-close timeout.



233
234
235
# File 'lib/temporalio/client/activity_execution.rb', line 233

def expiration_time
  Internal::ProtoUtils.timestamp_to_time(@raw_info.expiration_time)
end

#failure ⇒ Error::Failure?

Failure the activity closed with. Nil when the activity did not close with a failure or when Temporalio::Client::ActivityHandle#describe was called without include_outcome:.

This is the terminal outcome; #last_failure is the failure of the most recent attempt, which may be set while the activity is still retrying.

Returns:



185
186
187
188
189
# File 'lib/temporalio/client/activity_execution.rb', line 185

def failure
  return nil unless @raw_description.outcome&.value == :failure

  @data_converter.from_failure(@raw_description.outcome.failure)
end

#has_heartbeat_details? ⇒ Boolean

Whether heartbeat details are present on this description. False when the activity recorded none, and also when Temporalio::Client::ActivityHandle#describe was called without include_heartbeat_details:.

Returns:

  • (Boolean) —

    Whether heartbeat details are present.



128
129
130
# File 'lib/temporalio/client/activity_execution.rb', line 128

def has_heartbeat_details? # rubocop:disable Naming/PredicatePrefix
  !@raw_info.heartbeat_details&.payloads.nil? && !@raw_info.heartbeat_details.payloads.empty?
end

#has_input? ⇒ Boolean

Whether the activity's input is present. False unless Temporalio::Client::ActivityHandle#describe was called with include_input:.

Returns:

  • (Boolean) —

    Whether input is present.



144
145
146
# File 'lib/temporalio/client/activity_execution.rb', line 144

def has_input? # rubocop:disable Naming/PredicatePrefix
  !@raw_description.input.nil?
end

#has_last_failure? ⇒ Boolean

Whether a last failure is present on this description. False when the activity has no failed attempt, and also when Temporalio::Client::ActivityHandle#describe was called without include_last_failure:.

Returns:

  • (Boolean) —

    Whether a last failure is present.



221
222
223
# File 'lib/temporalio/client/activity_execution.rb', line 221

def has_last_failure? # rubocop:disable Naming/PredicatePrefix
  !@raw_info.last_failure.nil?
end

#has_result? ⇒ Boolean

Whether the activity closed with a successful result. False while the activity is still running, when it closed with a failure, and when Temporalio::Client::ActivityHandle#describe was called without include_outcome:.

Returns:

  • (Boolean) —

    Whether a result is present.



161
162
163
# File 'lib/temporalio/client/activity_execution.rb', line 161

def has_result? # rubocop:disable Naming/PredicatePrefix
  @raw_description.outcome&.value == :result
end

#heartbeat_details(hints: nil) ⇒ Array<Object>

Deserialized last-heartbeat details. Empty when no heartbeat has been recorded.

Parameters:

  • hints (Array<Object>, nil) (defaults to: nil) —

    Hints, if any, to assist conversion.

Returns:

  • (Array<Object>) —

    Converted details.



136
137
138
# File 'lib/temporalio/client/activity_execution.rb', line 136

def heartbeat_details(hints: nil)
  @data_converter.from_payloads(@raw_info.heartbeat_details, hints:)
end

#heartbeat_timeout ⇒ Float?

Returns Heartbeat timeout in seconds.

Returns:

  • (Float, nil) —

    Heartbeat timeout in seconds.



113
114
115
# File 'lib/temporalio/client/activity_execution.rb', line 113

def heartbeat_timeout
  Internal::ProtoUtils.duration_to_seconds(@raw_info.heartbeat_timeout)
end

#input(hints: nil) ⇒ Array<Object>

Deserialized activity input, one element per argument. Empty when no input is present.

Parameters:

  • hints (Array<Object>, nil) (defaults to: nil) —

    Hints, if any, to assist conversion.

Returns:

  • (Array<Object>) —

    Converted arguments.



152
153
154
# File 'lib/temporalio/client/activity_execution.rb', line 152

def input(hints: nil)
  @data_converter.from_payloads(@raw_description.input, hints:)
end

#last_attempt_complete_time ⇒ Time?

Returns Time when the last attempt completed.

Returns:

  • (Time, nil) —

    Time when the last attempt completed.



248
249
250
# File 'lib/temporalio/client/activity_execution.rb', line 248

def last_attempt_complete_time
  Internal::ProtoUtils.timestamp_to_time(@raw_info.last_attempt_complete_time)
end

#last_deployment_version ⇒ WorkerDeploymentVersion?

Returns Worker deployment version this activity was last dispatched to.

Returns:



258
259
260
261
262
263
264
265
266
# File 'lib/temporalio/client/activity_execution.rb', line 258

def last_deployment_version
  raw = @raw_info.last_deployment_version
  return nil unless raw

  WorkerDeploymentVersion.new(
    deployment_name: raw.deployment_name,
    build_id: raw.build_id
  )
end

#last_failure ⇒ Error::Failure?

Returns Failure of the last failed attempt if any.

Returns:

  • (Error::Failure, nil) —

    Failure of the last failed attempt if any.



226
227
228
229
230
# File 'lib/temporalio/client/activity_execution.rb', line 226

def last_failure
  return nil unless @raw_info.last_failure

  @data_converter.from_failure(@raw_info.last_failure)
end

#last_heartbeat_time ⇒ Time?

Returns Time the last heartbeat was recorded.

Returns:

  • (Time, nil) —

    Time the last heartbeat was recorded.



197
198
199
# File 'lib/temporalio/client/activity_execution.rb', line 197

def last_heartbeat_time
  Internal::ProtoUtils.timestamp_to_time(@raw_info.last_heartbeat_time)
end

#last_started_time ⇒ Time?

Returns Time the last attempt started.

Returns:

  • (Time, nil) —

    Time the last attempt started.



202
203
204
# File 'lib/temporalio/client/activity_execution.rb', line 202

def last_started_time
  Internal::ProtoUtils.timestamp_to_time(@raw_info.last_started_time)
end

#last_worker_identity ⇒ String?

Returns Identity of the worker that last picked up this activity.

Returns:

  • (String, nil) —

    Identity of the worker that last picked up this activity.



238
239
240
# File 'lib/temporalio/client/activity_execution.rb', line 238

def last_worker_identity
  Internal::ProtoUtils.string_or(@raw_info.last_worker_identity, nil)
end

#next_attempt_schedule_time ⇒ Time?

Returns Time when the next attempt will be scheduled.

Returns:

  • (Time, nil) —

    Time when the next attempt will be scheduled.



253
254
255
# File 'lib/temporalio/client/activity_execution.rb', line 253

def next_attempt_schedule_time
  Internal::ProtoUtils.timestamp_to_time(@raw_info.next_attempt_schedule_time)
end

#priority ⇒ Priority

Returns Priority of this activity.

Returns:

  • (Priority) —

    Priority of this activity.



269
270
271
# File 'lib/temporalio/client/activity_execution.rb', line 269

def priority
  Priority._from_proto(@raw_info.priority)
end

#result(result_hint: nil) ⇒ Object?

Deserialized result the activity closed with. Nil when no result is present (still running, closed with a failure, or include_outcome: was not requested).

Parameters:

  • result_hint (Object, nil) (defaults to: nil) —

    Hint, if any, to assist conversion.

Returns:

  • (Object, nil) —

    Converted result.



170
171
172
173
174
175
176
# File 'lib/temporalio/client/activity_execution.rb', line 170

def result(result_hint: nil)
  return nil unless has_result?

  @data_converter.from_payloads(
    @raw_description.outcome.result, hints: Array(result_hint)
  ).first
end

#retry_policy ⇒ RetryPolicy

Returns Retry policy in effect for this activity.

Returns:

  • (RetryPolicy) —

    Retry policy in effect for this activity.



192
193
194
# File 'lib/temporalio/client/activity_execution.rb', line 192

def retry_policy
  RetryPolicy._from_proto(@raw_info.retry_policy)
end

#run_state ⇒ PendingActivityState?

Returns More detailed breakdown of the running state when the activity's status is RUNNING; nil otherwise.

Returns:

  • (PendingActivityState, nil) —

    More detailed breakdown of the running state when the activity's status is RUNNING; nil otherwise.



92
93
94
95
# File 'lib/temporalio/client/activity_execution.rb', line 92

def run_state
  Internal::ProtoUtils.enum_to_int(Api::Enums::V1::PendingActivityState, @raw_info.run_state,
                                   zero_means_nil: true)
end

#schedule_to_close_timeout ⇒ Float?

Returns Schedule-to-close timeout in seconds.

Returns:

  • (Float, nil) —

    Schedule-to-close timeout in seconds.



98
99
100
# File 'lib/temporalio/client/activity_execution.rb', line 98

def schedule_to_close_timeout
  Internal::ProtoUtils.duration_to_seconds(@raw_info.schedule_to_close_timeout)
end

#schedule_to_start_timeout ⇒ Float?

Returns Schedule-to-start timeout in seconds.

Returns:

  • (Float, nil) —

    Schedule-to-start timeout in seconds.



103
104
105
# File 'lib/temporalio/client/activity_execution.rb', line 103

def schedule_to_start_timeout
  Internal::ProtoUtils.duration_to_seconds(@raw_info.schedule_to_start_timeout)
end

#start_delay ⇒ Float?

Returns Delay in seconds before the first activity task is made available for dispatch. Not applied to retry attempts.

Returns:

  • (Float, nil) —

    Delay in seconds before the first activity task is made available for dispatch. Not applied to retry attempts.



119
120
121
# File 'lib/temporalio/client/activity_execution.rb', line 119

def start_delay
  Internal::ProtoUtils.duration_to_seconds(@raw_info.start_delay)
end

#start_to_close_timeout ⇒ Float?

Returns Start-to-close timeout in seconds.

Returns:

  • (Float, nil) —

    Start-to-close timeout in seconds.



108
109
110
# File 'lib/temporalio/client/activity_execution.rb', line 108

def start_to_close_timeout
  Internal::ProtoUtils.duration_to_seconds(@raw_info.start_to_close_timeout)
end

#static_details ⇒ String?

Returns Static user-metadata details on the activity. May be in markdown format.

Returns:

  • (String, nil) —

    Static user-metadata details on the activity. May be in markdown format.



284
285
286
# File 'lib/temporalio/client/activity_execution.rb', line 284

def static_details
  .last
end

#summary ⇒ String?

Returns Static user-metadata summary on the activity.

Returns:

  • (String, nil) —

    Static user-metadata summary on the activity.



279
280
281
# File 'lib/temporalio/client/activity_execution.rb', line 279

def summary
  .first
end

#total_heartbeat_count ⇒ Integer

Returns Total number of heartbeats recorded across all attempts.

Returns:

  • (Integer) —

    Total number of heartbeats recorded across all attempts.



212
213
214
# File 'lib/temporalio/client/activity_execution.rb', line 212

def total_heartbeat_count
  @raw_info.total_heartbeat_count
end