Skip to content

Commit 143e421

Browse files
authored
Activity pause support (#283)
Fixes #241
1 parent 2d764b5 commit 143e421

File tree

26 files changed

+466
-18
lines changed

26 files changed

+466
-18
lines changed

temporalio/ext/src/client_rpc_generated.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,9 @@ impl Client {
562562
"add_namespace_region" => {
563563
rpc_call!(self, callback, call, CloudService, add_namespace_region)
564564
}
565+
"add_user_group_member" => {
566+
rpc_call!(self, callback, call, CloudService, add_user_group_member)
567+
}
565568
"create_api_key" => rpc_call!(self, callback, call, CloudService, create_api_key),
566569
"create_namespace" => {
567570
rpc_call!(self, callback, call, CloudService, create_namespace)
@@ -594,6 +597,9 @@ impl Client {
594597
CloudService,
595598
delete_namespace_export_sink
596599
),
600+
"delete_namespace_region" => {
601+
rpc_call!(self, callback, call, CloudService, delete_namespace_region)
602+
}
597603
"delete_nexus_endpoint" => {
598604
rpc_call!(self, callback, call, CloudService, delete_nexus_endpoint)
599605
}
@@ -650,8 +656,14 @@ impl Client {
650656
"get_usage" => rpc_call!(self, callback, call, CloudService, get_usage),
651657
"get_user" => rpc_call!(self, callback, call, CloudService, get_user),
652658
"get_user_group" => rpc_call!(self, callback, call, CloudService, get_user_group),
659+
"get_user_group_members" => {
660+
rpc_call!(self, callback, call, CloudService, get_user_group_members)
661+
}
653662
"get_user_groups" => rpc_call!(self, callback, call, CloudService, get_user_groups),
654663
"get_users" => rpc_call!(self, callback, call, CloudService, get_users),
664+
"remove_user_group_member" => {
665+
rpc_call!(self, callback, call, CloudService, remove_user_group_member)
666+
}
655667
"rename_custom_search_attribute" => rpc_call!(
656668
self,
657669
callback,

temporalio/lib/temporalio/activity.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# frozen_string_literal: true
22

3+
require 'temporalio/activity/cancellation_details'
34
require 'temporalio/activity/complete_async_error'
45
require 'temporalio/activity/context'
56
require 'temporalio/activity/definition'
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# frozen_string_literal: true
2+
3+
require 'temporalio/error'
4+
5+
module Temporalio
6+
module Activity
7+
# Details that are set when an activity is cancelled. This is only valid at the time the cancel was received, the
8+
# state may change on the server after it is received.
9+
class CancellationDetails
10+
def initialize(
11+
gone_from_server: false,
12+
cancel_requested: true,
13+
timed_out: false,
14+
worker_shutdown: false,
15+
paused: false,
16+
reset: false
17+
)
18+
@gone_from_server = gone_from_server
19+
@cancel_requested = cancel_requested
20+
@timed_out = timed_out
21+
@worker_shutdown = worker_shutdown
22+
@paused = paused
23+
@reset = reset
24+
end
25+
26+
# @return [Boolean] Whether the activity no longer exists on the server (may already be completed or its workflow
27+
# may be completed).
28+
def gone_from_server?
29+
@gone_from_server
30+
end
31+
32+
# @return [Boolean] Whether the activity was explicitly cancelled.
33+
def cancel_requested?
34+
@cancel_requested
35+
end
36+
37+
# @return [Boolean] Whether the activity timeout caused activity to be marked cancelled.
38+
def timed_out?
39+
@timed_out
40+
end
41+
42+
# @return [Boolean] Whether the worker the activity is running on is shutting down.
43+
def worker_shutdown?
44+
@worker_shutdown
45+
end
46+
47+
# @return [Boolean] Whether the activity was explicitly paused.
48+
def paused?
49+
@paused
50+
end
51+
52+
# @return [Boolean] Whether the activity was explicitly reset.
53+
def reset?
54+
@reset
55+
end
56+
end
57+
end
58+
end

temporalio/lib/temporalio/activity/context.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ def cancellation
7070
raise NotImplementedError
7171
end
7272

73+
# @return [CancellationDetails, nil] Cancellation details if canceled. These are set just before cancellation is
74+
# actually canceled. These details only represent when the cancel was first performed. Once set, this object is
75+
# never mutated. Therefore, the situation on the server may have changed (e.g. unpause), but this still
76+
# represents the values when cancellation first occurred for this attempt.
77+
def cancellation_details
78+
raise NotImplementedError
79+
end
80+
7381
# @return [Cancellation] Cancellation that is canceled when the worker is shutting down. On worker shutdown, this
7482
# is canceled, then the `graceful_shutdown_period` is waited (default 0s), then the activity is canceled.
7583
def worker_shutdown_cancellation

0 commit comments

Comments
 (0)