Class: Temporal::Activity::AsyncToken

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

Constant Summary collapse

SEPARATOR =
'|'.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(namespace, activity_id, workflow_id, run_id) ⇒ AsyncToken

Returns a new instance of AsyncToken.



21
22
23
24
25
26
# File 'lib/temporal/activity/async_token.rb', line 21

def initialize(namespace, activity_id, workflow_id, run_id)
  @namespace = namespace
  @activity_id = activity_id
  @workflow_id = workflow_id
  @run_id = run_id
end

Instance Attribute Details

#activity_idObject (readonly)

Returns the value of attribute activity_id.



8
9
10
# File 'lib/temporal/activity/async_token.rb', line 8

def activity_id
  @activity_id
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



8
9
10
# File 'lib/temporal/activity/async_token.rb', line 8

def namespace
  @namespace
end

#run_idObject (readonly)

Returns the value of attribute run_id.



8
9
10
# File 'lib/temporal/activity/async_token.rb', line 8

def run_id
  @run_id
end

#workflow_idObject (readonly)

Returns the value of attribute workflow_id.



8
9
10
# File 'lib/temporal/activity/async_token.rb', line 8

def workflow_id
  @workflow_id
end

Class Method Details

.decode(token) ⇒ Object



14
15
16
17
18
19
# File 'lib/temporal/activity/async_token.rb', line 14

def self.decode(token)
  string = Base64.urlsafe_decode64(token)
  namespace, activity_id, workflow_id, run_id = string.split(SEPARATOR)

  new(namespace, activity_id, workflow_id, run_id)
end

.encode(namespace, activity_id, workflow_id, run_id) ⇒ Object



10
11
12
# File 'lib/temporal/activity/async_token.rb', line 10

def self.encode(namespace, activity_id, workflow_id, run_id)
  new(namespace, activity_id, workflow_id, run_id).to_s
end

Instance Method Details

#to_sObject



28
29
30
31
# File 'lib/temporal/activity/async_token.rb', line 28

def to_s
  parts = [namespace, activity_id, workflow_id, run_id]
  Base64.urlsafe_encode64(parts.join(SEPARATOR)).freeze
end