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.

WARNING: Standalone Activities are experimental.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#raw_descriptionApi::WorkflowService::V1::DescribeActivityExecutionResponse (readonly)

Returns Underlying protobuf response.

Returns:



85
86
87
# File 'lib/temporalio/client/activity_execution.rb', line 85

def raw_description
  @raw_description
end

Instance Method Details

#attemptInteger

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.



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

def attempt
  @raw_info.attempt
end

#canceled_reasonString?

Returns Reason given when cancellation was requested.

Returns:

  • (String, nil)

    Reason given when cancellation was requested.



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

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

#current_retry_intervalFloat?

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

Returns:

  • (Float, nil)

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



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

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

#expiration_timeTime?

Returns Schedule time + schedule-to-close timeout.

Returns:

  • (Time, nil)

    Schedule time + schedule-to-close timeout.



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

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

#failureError::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:



189
190
191
192
193
# File 'lib/temporalio/client/activity_execution.rb', line 189

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.



132
133
134
# File 'lib/temporalio/client/activity_execution.rb', line 132

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.



148
149
150
# File 'lib/temporalio/client/activity_execution.rb', line 148

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.



225
226
227
# File 'lib/temporalio/client/activity_execution.rb', line 225

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.



165
166
167
# File 'lib/temporalio/client/activity_execution.rb', line 165

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.



140
141
142
# File 'lib/temporalio/client/activity_execution.rb', line 140

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

#heartbeat_timeoutFloat?

Returns Heartbeat timeout in seconds.

Returns:

  • (Float, nil)

    Heartbeat timeout in seconds.



117
118
119
# File 'lib/temporalio/client/activity_execution.rb', line 117

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.



156
157
158
# File 'lib/temporalio/client/activity_execution.rb', line 156

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

#last_attempt_complete_timeTime?

Returns Time when the last attempt completed.

Returns:

  • (Time, nil)

    Time when the last attempt completed.



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

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

#last_deployment_versionWorkerDeploymentVersion?

Returns Worker deployment version this activity was last dispatched to.

Returns:



262
263
264
265
266
267
268
269
270
# File 'lib/temporalio/client/activity_execution.rb', line 262

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_failureError::Failure?

Returns Failure of the last failed attempt if any.

Returns:

  • (Error::Failure, nil)

    Failure of the last failed attempt if any.



230
231
232
233
234
# File 'lib/temporalio/client/activity_execution.rb', line 230

def last_failure
  return nil unless @raw_info.last_failure

  @data_converter.from_failure(@raw_info.last_failure)
end

#last_heartbeat_timeTime?

Returns Time the last heartbeat was recorded.

Returns:

  • (Time, nil)

    Time the last heartbeat was recorded.



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

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

#last_started_timeTime?

Returns Time the last attempt started.

Returns:

  • (Time, nil)

    Time the last attempt started.



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

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

#last_worker_identityString?

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

Returns:

  • (String, nil)

    Identity of the worker that last picked up this activity.



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

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

#next_attempt_schedule_timeTime?

Returns Time when the next attempt will be scheduled.

Returns:

  • (Time, nil)

    Time when the next attempt will be scheduled.



257
258
259
# File 'lib/temporalio/client/activity_execution.rb', line 257

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

#priorityPriority

Returns Priority of this activity.

Returns:

  • (Priority)

    Priority of this activity.



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

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.



174
175
176
177
178
179
180
# File 'lib/temporalio/client/activity_execution.rb', line 174

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_policyRetryPolicy

Returns Retry policy in effect for this activity.

Returns:

  • (RetryPolicy)

    Retry policy in effect for this activity.



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

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

#run_statePendingActivityState?

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.



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

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

#schedule_to_close_timeoutFloat?

Returns Schedule-to-close timeout in seconds.

Returns:

  • (Float, nil)

    Schedule-to-close timeout in seconds.



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

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

#schedule_to_start_timeoutFloat?

Returns Schedule-to-start timeout in seconds.

Returns:

  • (Float, nil)

    Schedule-to-start timeout in seconds.



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

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

#start_delayFloat?

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.



123
124
125
# File 'lib/temporalio/client/activity_execution.rb', line 123

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

#start_to_close_timeoutFloat?

Returns Start-to-close timeout in seconds.

Returns:

  • (Float, nil)

    Start-to-close timeout in seconds.



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

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

#static_detailsString?

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.



288
289
290
# File 'lib/temporalio/client/activity_execution.rb', line 288

def static_details
  .last
end

#static_summaryString?

Returns Static user-metadata summary on the activity.

Returns:

  • (String, nil)

    Static user-metadata summary on the activity.



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

def static_summary
  .first
end

#total_heartbeat_countInteger

Returns Total number of heartbeats recorded across all attempts.

Returns:

  • (Integer)

    Total number of heartbeats recorded across all attempts.



216
217
218
# File 'lib/temporalio/client/activity_execution.rb', line 216

def total_heartbeat_count
  @raw_info.total_heartbeat_count
end