class Cadence::Activity::Context

Attributes

client[R]
metadata[R]

Public Class Methods

new(client, metadata) click to toggle source
# File lib/cadence/activity/context.rb, line 10
def initialize(client, metadata)
  @client = client
  @metadata = metadata
  @async = false
end

Public Instance Methods

async() click to toggle source
# File lib/cadence/activity/context.rb, line 16
def async
  @async = true
end
async?() click to toggle source
# File lib/cadence/activity/context.rb, line 20
def async?
  @async
end
async_token() click to toggle source
# File lib/cadence/activity/context.rb, line 24
def async_token
  AsyncToken.encode(
    metadata.domain,
    metadata.id,
    metadata.workflow_id,
    metadata.workflow_run_id
  )
end
headers() click to toggle source
# File lib/cadence/activity/context.rb, line 51
def headers
  metadata.headers
end
heartbeat(details = nil) click to toggle source
# File lib/cadence/activity/context.rb, line 33
def heartbeat(details = nil)
  logger.debug('Activity heartbeat')
  client.record_activity_task_heartbeat(task_token: task_token, details: details)
end
idem()
Alias for: run_idem
logger() click to toggle source
# File lib/cadence/activity/context.rb, line 38
def logger
  Cadence.logger
end
run_idem() click to toggle source
# File lib/cadence/activity/context.rb, line 42
def run_idem
  UUID.v5(metadata.workflow_run_id.to_s, metadata.id.to_s)
end
Also aliased as: idem
workflow_idem() click to toggle source
# File lib/cadence/activity/context.rb, line 47
def workflow_idem
  UUID.v5(metadata.workflow_id.to_s, metadata.id.to_s)
end

Private Instance Methods

task_token() click to toggle source
# File lib/cadence/activity/context.rb, line 59
def task_token
  metadata.task_token
end