Class: Temporal::Activity::Context
- Inherits:
-
Object
- Object
- Temporal::Activity::Context
show all
- Defined in:
- lib/temporal/activity/context.rb
Instance Method Summary
collapse
Constructor Details
#initialize(client, metadata) ⇒ Context
Returns a new instance of Context.
10
11
12
13
14
|
# File 'lib/temporal/activity/context.rb', line 10
def initialize(client, metadata)
@client = client
@metadata = metadata
@async = false
end
|
Instance Method Details
#async ⇒ Object
16
17
18
|
# File 'lib/temporal/activity/context.rb', line 16
def async
@async = true
end
|
#async? ⇒ Boolean
20
21
22
|
# File 'lib/temporal/activity/context.rb', line 20
def async?
@async
end
|
#async_token ⇒ Object
24
25
26
27
28
29
30
31
|
# File 'lib/temporal/activity/context.rb', line 24
def async_token
AsyncToken.encode(
metadata.namespace,
metadata.id,
metadata.workflow_id,
metadata.workflow_run_id
)
end
|
55
56
57
|
# File 'lib/temporal/activity/context.rb', line 55
def
metadata.
end
|
#heartbeat(details = nil) ⇒ Object
33
34
35
36
|
# File 'lib/temporal/activity/context.rb', line 33
def heartbeat(details = nil)
logger.debug("Activity heartbeat", metadata.to_h)
client.record_activity_task_heartbeat(task_token: task_token, details: details)
end
|
#heartbeat_details ⇒ Object
38
39
40
|
# File 'lib/temporal/activity/context.rb', line 38
def heartbeat_details
metadata.heartbeat_details
end
|
#logger ⇒ Object
42
43
44
|
# File 'lib/temporal/activity/context.rb', line 42
def logger
Temporal.logger
end
|
#run_idem ⇒ Object
Also known as:
idem
46
47
48
|
# File 'lib/temporal/activity/context.rb', line 46
def run_idem
UUID.v5(metadata.workflow_run_id.to_s, metadata.id.to_s)
end
|
#workflow_idem ⇒ Object
51
52
53
|
# File 'lib/temporal/activity/context.rb', line 51
def workflow_idem
UUID.v5(metadata.workflow_id.to_s, metadata.id.to_s)
end
|