Class: Temporal::Activity::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/temporal/activity/context.rb

Direct Known Subclasses

Testing::LocalActivityContext

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, )
  @client = client
  @metadata = 
  @async = false
end

Instance Method Details

#asyncObject



16
17
18
# File 'lib/temporal/activity/context.rb', line 16

def async
  @async = true
end

#async?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/temporal/activity/context.rb', line 20

def async?
  @async
end

#async_tokenObject



24
25
26
27
28
29
30
31
# File 'lib/temporal/activity/context.rb', line 24

def async_token
  AsyncToken.encode(
    .namespace,
    .id,
    .workflow_id,
    .workflow_run_id
  )
end

#headersObject



55
56
57
# File 'lib/temporal/activity/context.rb', line 55

def headers
  .headers
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", .to_h)
  client.record_activity_task_heartbeat(task_token: task_token, details: details)
end

#heartbeat_detailsObject



38
39
40
# File 'lib/temporal/activity/context.rb', line 38

def heartbeat_details
  .heartbeat_details
end

#loggerObject



42
43
44
# File 'lib/temporal/activity/context.rb', line 42

def logger
  Temporal.logger
end

#run_idemObject Also known as: idem



46
47
48
# File 'lib/temporal/activity/context.rb', line 46

def run_idem
  UUID.v5(.workflow_run_id.to_s, .id.to_s)
end

#workflow_idemObject



51
52
53
# File 'lib/temporal/activity/context.rb', line 51

def workflow_idem
  UUID.v5(.workflow_id.to_s, .id.to_s)
end