Class: Cadence::Activity::AsyncToken

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

Constant Summary collapse

SEPARATOR =
'|'.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of AsyncToken.



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

def initialize(domain, activity_id, workflow_id, run_id)
  @domain = domain
  @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/cadence/activity/async_token.rb', line 8

def activity_id
  @activity_id
end

#domainObject (readonly)

Returns the value of attribute domain.



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

def domain
  @domain
end

#run_idObject (readonly)

Returns the value of attribute run_id.



8
9
10
# File 'lib/cadence/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/cadence/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/cadence/activity/async_token.rb', line 14

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

  new(domain, activity_id, workflow_id, run_id)
end

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



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

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

Instance Method Details

#to_sObject



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

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