temporalio 1.4.1 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,26 +6,61 @@ require 'temporalio/error'
6
6
 
7
7
  module Temporalio
8
8
  class Client
9
- # Reference to an existing activity by its workflow ID, run ID, and activity ID.
9
+ # Reference to an activity for use with {Client#async_activity_handle}. There are two shapes,
10
+ # depending on whether the activity is run in a workflow, or as a standalone activity.
11
+ #
12
+ # 1. Activity run in a workflow -- use {ActivityIDReference#initialize}:
13
+ # `ActivityIDReference.new(workflow_id:, run_id:, activity_id:)`.
14
+ #
15
+ # 2. Standalone Activity (started via {Client#start_activity}): use the class factory
16
+ # {ActivityIDReference.for_standalone}: `ActivityIDReference.for_standalone(activity_id:, activity_run_id:)`.
10
17
  class ActivityIDReference
11
- # @return [String] ID for the workflow.
18
+ # @return [String] ID for the activity.
19
+ attr_reader :activity_id
20
+
21
+ # @return [String, nil] Activity run ID. Set only for standalone activity references.
22
+ attr_reader :activity_run_id
23
+
24
+ # @return [String, nil] ID for the workflow. Set only for workflow-run activity references.
12
25
  attr_reader :workflow_id
13
26
 
14
- # @return [String, nil] Run ID for the workflow.
27
+ # @return [String, nil] Run ID for the workflow. Set only for workflow-run activity references.
15
28
  attr_reader :run_id
16
29
 
17
- # @return [String] ID for the activity.
18
- attr_reader :activity_id
30
+ # Construct a standalone activity reference.
31
+ #
32
+ # WARNING: Standalone Activities are experimental.
33
+ #
34
+ # @param activity_id [String] ID for the activity.
35
+ # @param activity_run_id [String, nil] Run ID for the activity execution. nil targets the latest run.
36
+ # @return [ActivityIDReference] A reference suitable for {Client#async_activity_handle}.
37
+ def self.for_standalone(activity_id:, activity_run_id: nil)
38
+ allocate.tap do |ref|
39
+ ref.instance_variable_set(:@activity_id, activity_id)
40
+ ref.instance_variable_set(:@activity_run_id, activity_run_id)
41
+ ref.instance_variable_set(:@workflow_id, nil)
42
+ ref.instance_variable_set(:@run_id, nil)
43
+ end
44
+ end
19
45
 
20
- # Create an activity ID reference.
46
+ # Construct a workflow-run activity reference.
21
47
  #
22
48
  # @param workflow_id [String] ID for the workflow.
23
49
  # @param run_id [String, nil] Run ID for the workflow.
24
- # @param activity_id [String] ID for the workflow.
50
+ # @param activity_id [String] ID for the activity.
51
+ # @return [ActivityIDReference] A reference suitable for {Client#async_activity_handle}.
25
52
  def initialize(workflow_id:, run_id:, activity_id:)
26
53
  @workflow_id = workflow_id
27
54
  @run_id = run_id
28
55
  @activity_id = activity_id
56
+ @activity_run_id = nil
57
+ end
58
+
59
+ # @return [Boolean] True if this reference is the standalone-form (activity_run_id without workflow_id).
60
+ #
61
+ # WARNING: Standalone Activities are experimental.
62
+ def standalone?
63
+ @workflow_id.nil?
29
64
  end
30
65
  end
31
66
  end
@@ -259,6 +259,87 @@ module Temporalio
259
259
  :rpc_options
260
260
  )
261
261
 
262
+ # Input for {Outbound.start_activity}.
263
+ #
264
+ # WARNING: Standalone Activities are experimental.
265
+ StartActivityInput = Data.define(
266
+ :activity,
267
+ :args,
268
+ :activity_id,
269
+ :task_queue,
270
+ :schedule_to_close_timeout,
271
+ :schedule_to_start_timeout,
272
+ :start_to_close_timeout,
273
+ :heartbeat_timeout,
274
+ :id_reuse_policy,
275
+ :id_conflict_policy,
276
+ :retry_policy,
277
+ :search_attributes,
278
+ :static_summary,
279
+ :static_details,
280
+ :headers,
281
+ :priority,
282
+ :start_delay,
283
+ :arg_hints,
284
+ :result_hint,
285
+ :rpc_options
286
+ )
287
+
288
+ # Input for {Outbound.describe_activity}.
289
+ #
290
+ # WARNING: Standalone Activities are experimental.
291
+ DescribeActivityInput = Data.define(
292
+ :activity_id,
293
+ :activity_run_id,
294
+ :rpc_options
295
+ )
296
+
297
+ # Input for {Outbound.cancel_activity}.
298
+ #
299
+ # WARNING: Standalone Activities are experimental.
300
+ CancelActivityInput = Data.define(
301
+ :activity_id,
302
+ :activity_run_id,
303
+ :reason,
304
+ :rpc_options
305
+ )
306
+
307
+ # Input for {Outbound.terminate_activity}.
308
+ #
309
+ # WARNING: Standalone Activities are experimental.
310
+ TerminateActivityInput = Data.define(
311
+ :activity_id,
312
+ :activity_run_id,
313
+ :reason,
314
+ :rpc_options
315
+ )
316
+
317
+ # Input for {Outbound.list_activities}.
318
+ #
319
+ # WARNING: Standalone Activities are experimental.
320
+ ListActivitiesInput = Data.define(
321
+ :query,
322
+ :rpc_options
323
+ )
324
+
325
+ # Input for {Outbound.count_activities}.
326
+ #
327
+ # WARNING: Standalone Activities are experimental.
328
+ CountActivitiesInput = Data.define(
329
+ :query,
330
+ :rpc_options
331
+ )
332
+
333
+ # Input for {Outbound.fetch_activity_outcome}. Used by `ActivityHandle#result` for long-polling
334
+ # the activity outcome via `PollActivityExecution`.
335
+ #
336
+ # WARNING: Standalone Activities are experimental.
337
+ FetchActivityOutcomeInput = Data.define(
338
+ :activity_id,
339
+ :activity_run_id,
340
+ :rpc_options
341
+ )
342
+
262
343
  # Outbound interceptor for intercepting client calls. This should be extended by users needing to intercept client
263
344
  # actions.
264
345
  class Outbound
@@ -467,6 +548,74 @@ module Temporalio
467
548
  def report_cancellation_async_activity(input)
468
549
  next_interceptor.report_cancellation_async_activity(input)
469
550
  end
551
+
552
+ # Called for every {Client.start_activity} and {Client.execute_activity} call.
553
+ #
554
+ # WARNING: Standalone Activities are experimental.
555
+ #
556
+ # @param input [StartActivityInput] Input.
557
+ # @return [ActivityHandle] Activity handle.
558
+ def start_activity(input)
559
+ next_interceptor.start_activity(input)
560
+ end
561
+
562
+ # Called for every {ActivityHandle.describe} call.
563
+ #
564
+ # WARNING: Standalone Activities are experimental.
565
+ #
566
+ # @param input [DescribeActivityInput] Input.
567
+ # @return [ActivityExecution::Description] Activity description.
568
+ def describe_activity(input)
569
+ next_interceptor.describe_activity(input)
570
+ end
571
+
572
+ # Called for every {ActivityHandle.cancel} call.
573
+ #
574
+ # WARNING: Standalone Activities are experimental.
575
+ #
576
+ # @param input [CancelActivityInput] Input.
577
+ def cancel_activity(input)
578
+ next_interceptor.cancel_activity(input)
579
+ end
580
+
581
+ # Called for every {ActivityHandle.terminate} call.
582
+ #
583
+ # WARNING: Standalone Activities are experimental.
584
+ #
585
+ # @param input [TerminateActivityInput] Input.
586
+ def terminate_activity(input)
587
+ next_interceptor.terminate_activity(input)
588
+ end
589
+
590
+ # Called for every {Client.list_activities} call.
591
+ #
592
+ # WARNING: Standalone Activities are experimental.
593
+ #
594
+ # @param input [ListActivitiesInput] Input.
595
+ # @return [Enumerator<ActivityExecution>] Activity executions.
596
+ def list_activities(input)
597
+ next_interceptor.list_activities(input)
598
+ end
599
+
600
+ # Called for every {Client.count_activities} call.
601
+ #
602
+ # WARNING: Standalone Activities are experimental.
603
+ #
604
+ # @param input [CountActivitiesInput] Input.
605
+ # @return [ActivityExecutionCount] Activity count.
606
+ def count_activities(input)
607
+ next_interceptor.count_activities(input)
608
+ end
609
+
610
+ # Called by {ActivityHandle.result} to long-poll the activity outcome.
611
+ #
612
+ # WARNING: Standalone Activities are experimental.
613
+ #
614
+ # @param input [FetchActivityOutcomeInput] Input.
615
+ # @return [Api::Activity::V1::ActivityExecutionOutcome] Activity outcome.
616
+ def fetch_activity_outcome(input)
617
+ next_interceptor.fetch_activity_outcome(input)
618
+ end
470
619
  end
471
620
  end
472
621
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'temporalio/api'
4
+
5
+ module Temporalio
6
+ class Client
7
+ # More detailed breakdown of a running activity's state.
8
+ #
9
+ # WARNING: Standalone Activities are experimental.
10
+ module PendingActivityState
11
+ SCHEDULED = Api::Enums::V1::PendingActivityState::PENDING_ACTIVITY_STATE_SCHEDULED
12
+ STARTED = Api::Enums::V1::PendingActivityState::PENDING_ACTIVITY_STATE_STARTED
13
+ CANCEL_REQUESTED = Api::Enums::V1::PendingActivityState::PENDING_ACTIVITY_STATE_CANCEL_REQUESTED
14
+ PAUSED = Api::Enums::V1::PendingActivityState::PENDING_ACTIVITY_STATE_PAUSED
15
+ PAUSE_REQUESTED = Api::Enums::V1::PendingActivityState::PENDING_ACTIVITY_STATE_PAUSE_REQUESTED
16
+ end
17
+ end
18
+ end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'temporalio/common_enums'
4
+ require 'temporalio/priority'
4
5
 
5
6
  module Temporalio
6
7
  class Client
@@ -24,6 +25,7 @@ module Temporalio
24
25
  :memo,
25
26
  :search_attributes,
26
27
  :start_delay,
28
+ :priority,
27
29
  :arg_hints,
28
30
  :result_hint,
29
31
  :headers
@@ -40,6 +42,8 @@ module Temporalio
40
42
  #
41
43
  # Note, for {Client.start_update_with_start_workflow} and {Client.execute_update_with_start_workflow},
42
44
  # `id_conflict_policy` is required.
45
+ #
46
+ # @param priority [Priority] Priority of the workflow that may be started. This is currently experimental.
43
47
  def initialize(
44
48
  workflow,
45
49
  *args,
@@ -57,6 +61,7 @@ module Temporalio
57
61
  memo: nil,
58
62
  search_attributes: nil,
59
63
  start_delay: nil,
64
+ priority: Priority.default,
60
65
  arg_hints: nil,
61
66
  result_hint: nil,
62
67
  headers: {}
@@ -80,6 +85,7 @@ module Temporalio
80
85
  memo:,
81
86
  search_attributes:,
82
87
  start_delay:,
88
+ priority:,
83
89
  arg_hints: arg_hints || defn_arg_hints,
84
90
  result_hint: result_hint || defn_result_hint,
85
91
  headers:
@@ -3,6 +3,7 @@
3
3
  require 'google/protobuf/well_known_types'
4
4
  require 'logger'
5
5
  require 'temporalio/api'
6
+ require 'temporalio/client/activity_handle'
6
7
  require 'temporalio/client/async_activity_handle'
7
8
  require 'temporalio/client/connection'
8
9
  require 'temporalio/client/interceptor'
@@ -478,6 +479,209 @@ module Temporalio
478
479
  )
479
480
  end
480
481
 
482
+ # Get a handle for an existing standalone activity. Useful when the activity was started elsewhere
483
+ # (a different process, or by another client) and you have only its ID.
484
+ #
485
+ # WARNING: Standalone Activities are experimental.
486
+ #
487
+ # @param activity_id [String] ID for the activity.
488
+ # @param activity_run_id [String, nil] Run ID for the activity execution. If nil, operations target the
489
+ # latest run of the given activity ID.
490
+ # @param result_hint [Object, nil] Converter hint for the activity's result. Set this when you know what
491
+ # type the activity returns so {ActivityHandle#result}'s deserialization uses the right hint.
492
+ #
493
+ # @return [ActivityHandle] The activity handle.
494
+ def activity_handle(activity_id, activity_run_id: nil, result_hint: nil)
495
+ ActivityHandle.new(client: self, id: activity_id, run_id: activity_run_id, result_hint:)
496
+ end
497
+
498
+ # Start a standalone activity execution and return its handle.
499
+ #
500
+ # WARNING: Standalone Activities are experimental.
501
+ #
502
+ # @param activity [Class<Activity::Definition>, Activity::Definition, Activity::Definition::Info, Symbol, String]
503
+ # Activity definition, definition class or activity name.
504
+ # @param args [Array<Object>] Arguments to the activity.
505
+ # @param id [String] Unique identifier for the activity execution.
506
+ # @param task_queue [String] Task queue to run the activity on.
507
+ # @param schedule_to_close_timeout [Float, nil] Schedule-to-close timeout in seconds. Either this or
508
+ # `start_to_close_timeout` must be specified.
509
+ # @param schedule_to_start_timeout [Float, nil] Schedule-to-start timeout in seconds.
510
+ # @param start_to_close_timeout [Float, nil] Start-to-close timeout in seconds. Either this or
511
+ # `schedule_to_close_timeout` must be specified.
512
+ # @param heartbeat_timeout [Float, nil] Heartbeat timeout in seconds.
513
+ # @param id_reuse_policy [ActivityIDReusePolicy] Controls behavior when an activity with the same ID
514
+ # was previously run and has reached a terminal state. Defaults to `ALLOW_DUPLICATE`.
515
+ # @param id_conflict_policy [ActivityIDConflictPolicy] Controls behavior when an activity with the same ID
516
+ # is currently running. Defaults to `FAIL` (reject the start attempt).
517
+ # @param retry_policy [RetryPolicy, nil] Retry policy for the activity.
518
+ # @param search_attributes [SearchAttributes, nil] Search attributes for the activity.
519
+ # @param static_summary [String, nil] Fixed single-line summary for this activity execution.
520
+ # @param static_details [String, nil] Fixed details for this activity execution. May be in markdown format.
521
+ # @param priority [Priority] Priority for the activity. This is currently experimental.
522
+ # @param start_delay [Float, nil] Time (in seconds) to wait before dispatching the first activity task. This delay
523
+ # is not applied to retry attempts. `nil` or `0` means no delay. Negative values raise `ArgumentError`.
524
+ # This is currently experimental.
525
+ # @param arg_hints [Array<Object>, nil] Argument hints.
526
+ # @param result_hint [Object, nil] Result hint.
527
+ # @param rpc_options [RPCOptions, nil] Advanced RPC options.
528
+ #
529
+ # @return [ActivityHandle] Handle to the started activity.
530
+ # @raise [Error::ActivityAlreadyStartedError] Activity already exists with this ID.
531
+ # @raise [Error::RPCError] RPC error from call.
532
+ def start_activity(
533
+ activity,
534
+ *args,
535
+ id:,
536
+ task_queue:,
537
+ schedule_to_close_timeout: nil,
538
+ schedule_to_start_timeout: nil,
539
+ start_to_close_timeout: nil,
540
+ heartbeat_timeout: nil,
541
+ id_reuse_policy: ActivityIDReusePolicy::ALLOW_DUPLICATE,
542
+ id_conflict_policy: ActivityIDConflictPolicy::FAIL,
543
+ retry_policy: nil,
544
+ search_attributes: nil,
545
+ static_summary: nil,
546
+ static_details: nil,
547
+ priority: Priority.default,
548
+ start_delay: nil,
549
+ arg_hints: nil,
550
+ result_hint: nil,
551
+ rpc_options: nil
552
+ )
553
+ activity_name, defn_arg_hints, defn_result_hint =
554
+ Activity::Definition::Info._type_and_hints_from_parameter(activity)
555
+ @impl.start_activity(Interceptor::StartActivityInput.new(
556
+ activity: activity_name,
557
+ args:,
558
+ activity_id: id,
559
+ task_queue:,
560
+ schedule_to_close_timeout:,
561
+ schedule_to_start_timeout:,
562
+ start_to_close_timeout:,
563
+ heartbeat_timeout:,
564
+ id_reuse_policy:,
565
+ id_conflict_policy:,
566
+ retry_policy:,
567
+ search_attributes:,
568
+ static_summary:,
569
+ static_details:,
570
+ headers: {},
571
+ priority:,
572
+ start_delay:,
573
+ arg_hints: arg_hints || defn_arg_hints,
574
+ result_hint: result_hint || defn_result_hint,
575
+ rpc_options:
576
+ ))
577
+ end
578
+
579
+ # Start a standalone activity execution and wait for its result. Shortcut for
580
+ # {start_activity} + {ActivityHandle#result}.
581
+ #
582
+ # WARNING: Standalone Activities are experimental.
583
+ #
584
+ # @param activity [Class<Activity::Definition>, Activity::Definition, Activity::Definition::Info, Symbol, String]
585
+ # Activity definition, definition class or activity name.
586
+ # @param args [Array<Object>] Arguments to the activity.
587
+ # @param id [String] Unique identifier for the activity execution.
588
+ # @param task_queue [String] Task queue to run the activity on.
589
+ # @param schedule_to_close_timeout [Float, nil] Schedule-to-close timeout in seconds. Either this or
590
+ # `start_to_close_timeout` must be specified.
591
+ # @param schedule_to_start_timeout [Float, nil] Schedule-to-start timeout in seconds.
592
+ # @param start_to_close_timeout [Float, nil] Start-to-close timeout in seconds. Either this or
593
+ # `schedule_to_close_timeout` must be specified.
594
+ # @param heartbeat_timeout [Float, nil] Heartbeat timeout in seconds.
595
+ # @param id_reuse_policy [ActivityIDReusePolicy] Controls behavior when an activity with the same ID
596
+ # was previously run and has reached a terminal state. Defaults to `ALLOW_DUPLICATE`.
597
+ # @param id_conflict_policy [ActivityIDConflictPolicy] Controls behavior when an activity with the same ID
598
+ # is currently running. Defaults to `FAIL` (reject the start attempt).
599
+ # @param retry_policy [RetryPolicy, nil] Retry policy for the activity.
600
+ # @param search_attributes [SearchAttributes, nil] Search attributes for the activity.
601
+ # @param static_summary [String, nil] Fixed single-line summary for this activity execution.
602
+ # @param static_details [String, nil] Fixed details for this activity execution. May be in markdown format.
603
+ # @param priority [Priority] Priority for the activity. This is currently experimental.
604
+ # @param start_delay [Float, nil] Time (in seconds) to wait before dispatching the first activity task. This delay
605
+ # is not applied to retry attempts. `nil` or `0` means no delay. Negative values raise `ArgumentError`.
606
+ # This is currently experimental.
607
+ # @param arg_hints [Array<Object>, nil] Argument hints.
608
+ # @param result_hint [Object, nil] Result hint.
609
+ # @param rpc_options [RPCOptions, nil] Advanced RPC options.
610
+ #
611
+ # @return [Object, nil] Successful result of the activity.
612
+ # @raise [Error::ActivityAlreadyStartedError] Activity already exists with this ID.
613
+ # @raise [Error::ActivityFailedError] With `cause` populated from the activity failure.
614
+ # @raise [Error::RPCError] RPC error from call.
615
+ def execute_activity(
616
+ activity,
617
+ *args,
618
+ id:,
619
+ task_queue:,
620
+ schedule_to_close_timeout: nil,
621
+ schedule_to_start_timeout: nil,
622
+ start_to_close_timeout: nil,
623
+ heartbeat_timeout: nil,
624
+ id_reuse_policy: ActivityIDReusePolicy::ALLOW_DUPLICATE,
625
+ id_conflict_policy: ActivityIDConflictPolicy::FAIL,
626
+ retry_policy: nil,
627
+ search_attributes: nil,
628
+ static_summary: nil,
629
+ static_details: nil,
630
+ priority: Priority.default,
631
+ start_delay: nil,
632
+ arg_hints: nil,
633
+ result_hint: nil,
634
+ rpc_options: nil
635
+ )
636
+ start_activity(
637
+ activity,
638
+ *args,
639
+ id:,
640
+ task_queue:,
641
+ schedule_to_close_timeout:,
642
+ schedule_to_start_timeout:,
643
+ start_to_close_timeout:,
644
+ heartbeat_timeout:,
645
+ id_reuse_policy:,
646
+ id_conflict_policy:,
647
+ retry_policy:,
648
+ search_attributes:,
649
+ static_summary:,
650
+ static_details:,
651
+ priority:,
652
+ start_delay:,
653
+ arg_hints:,
654
+ result_hint:,
655
+ rpc_options:
656
+ ).result
657
+ end
658
+
659
+ # List standalone activities matching a visibility query.
660
+ #
661
+ # WARNING: Standalone Activities are experimental.
662
+ #
663
+ # @param query [String] Visibility list filter.
664
+ # @param rpc_options [RPCOptions, nil] Advanced RPC options.
665
+ #
666
+ # @return [Enumerator<ActivityExecution>] Lazy enumerable of matching activity executions.
667
+ # @raise [Error::RPCError] RPC error from call.
668
+ def list_activities(query, rpc_options: nil)
669
+ @impl.list_activities(Interceptor::ListActivitiesInput.new(query:, rpc_options:))
670
+ end
671
+
672
+ # Count standalone activities matching a visibility query.
673
+ #
674
+ # WARNING: Standalone Activities are experimental.
675
+ #
676
+ # @param query [String] Visibility list filter.
677
+ # @param rpc_options [RPCOptions, nil] Advanced RPC options.
678
+ #
679
+ # @return [ActivityExecutionCount] Count of activities (with per-group counts if the query had a group-by clause).
680
+ # @raise [Error::RPCError] RPC error from call.
681
+ def count_activities(query, rpc_options: nil)
682
+ @impl.count_activities(Interceptor::CountActivitiesInput.new(query:, rpc_options:))
683
+ end
684
+
481
685
  # Start an update, possibly starting the workflow at the same time if it doesn't exist (depending upon ID conflict
482
686
  # policy). Note that in some cases this may fail but the workflow will still be started, and the handle can then be
483
687
  # retrieved on the start workflow operation.
@@ -84,6 +84,34 @@ module Temporalio
84
84
  Api::Enums::V1::SuggestContinueAsNewReason::SUGGEST_CONTINUE_AS_NEW_REASON_TOO_MANY_UPDATES
85
85
  end
86
86
 
87
+ # Controls behavior when an activity with the same ID was previously run and is now closed.
88
+ #
89
+ # WARNING: Standalone Activities are experimental.
90
+ #
91
+ # @see https://docs.temporal.io/activities
92
+ module ActivityIDReusePolicy
93
+ # Always allow starting an activity using the same activity ID.
94
+ ALLOW_DUPLICATE = Api::Enums::V1::ActivityIdReusePolicy::ACTIVITY_ID_REUSE_POLICY_ALLOW_DUPLICATE
95
+ # Allow starting an activity using the same ID only when the last activity execution was not successful.
96
+ ALLOW_DUPLICATE_FAILED_ONLY =
97
+ Api::Enums::V1::ActivityIdReusePolicy::ACTIVITY_ID_REUSE_POLICY_ALLOW_DUPLICATE_FAILED_ONLY
98
+ # Do not permit re-use of the ID for this activity. Future start requests could potentially change the policy,
99
+ # allowing re-use of the ID.
100
+ REJECT_DUPLICATE = Api::Enums::V1::ActivityIdReusePolicy::ACTIVITY_ID_REUSE_POLICY_REJECT_DUPLICATE
101
+ end
102
+
103
+ # Controls behavior when an activity with the same ID is currently running.
104
+ #
105
+ # WARNING: Standalone Activities are experimental.
106
+ #
107
+ # @see https://docs.temporal.io/activities
108
+ module ActivityIDConflictPolicy
109
+ # Don't start a new activity; instead fail with already-started error.
110
+ FAIL = Api::Enums::V1::ActivityIdConflictPolicy::ACTIVITY_ID_CONFLICT_POLICY_FAIL
111
+ # Don't start a new activity; instead return a handle for the running activity.
112
+ USE_EXISTING = Api::Enums::V1::ActivityIdConflictPolicy::ACTIVITY_ID_CONFLICT_POLICY_USE_EXISTING
113
+ end
114
+
87
115
  # Specifies when a workflow might move from a worker of one Build Id to another.
88
116
  module VersioningBehavior
89
117
  # Unspecified versioning behavior. By default, workers opting into worker versioning will
@@ -29,6 +29,28 @@ module Temporalio
29
29
  end
30
30
  end
31
31
 
32
+ # Error raised by a client when a standalone activity execution has already started.
33
+ #
34
+ # WARNING: Standalone Activities are experimental.
35
+ class ActivityAlreadyStartedError < Failure
36
+ # @return [String] ID of the already-started activity.
37
+ attr_reader :activity_id
38
+
39
+ # @return [String] Activity type name of the already-started activity.
40
+ attr_reader :activity_type
41
+
42
+ # @return [String, nil] Run ID of the already-started activity if known.
43
+ attr_reader :activity_run_id
44
+
45
+ # @!visibility private
46
+ def initialize(activity_id:, activity_type:, activity_run_id:)
47
+ super('Activity execution already started')
48
+ @activity_id = activity_id
49
+ @activity_type = activity_type
50
+ @activity_run_id = activity_run_id
51
+ end
52
+ end
53
+
32
54
  # Error raised during workflow/activity execution.
33
55
  class ApplicationError < Failure
34
56
  # @return [Array<Object, nil>] User-defined details on the error.
@@ -40,6 +40,17 @@ module Temporalio
40
40
  end
41
41
  end
42
42
 
43
+ # Error returned from {Client::ActivityHandle#result} when the activity did not complete successfully.
44
+ # The specific activity failure can be accessed via `cause`.
45
+ #
46
+ # WARNING: Standalone Activities are experimental.
47
+ class ActivityFailedError < Error
48
+ # @!visibility private
49
+ def initialize(message = 'Activity execution failed')
50
+ super
51
+ end
52
+ end
53
+
43
54
  # Error that occurs when a workflow was continued as new.
44
55
  class WorkflowContinuedAsNewError < Error
45
56
  # @return [String] New execution run ID the workflow continued to.