Class: JFlow::Domain

Inherits:
Object
  • Object
show all
Defined in:
lib/jflow/domain.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(domain_name) ⇒ Domain

Returns a new instance of Domain.



6
7
8
9
# File 'lib/jflow/domain.rb', line 6

def initialize(domain_name)
  @domain_name = domain_name
  create unless exists?
end

Instance Attribute Details

#domain_nameObject (readonly)

Returns the value of attribute domain_name.



4
5
6
# File 'lib/jflow/domain.rb', line 4

def domain_name
  @domain_name
end

Instance Method Details

#createObject



11
12
13
14
15
16
17
18
# File 'lib/jflow/domain.rb', line 11

def create
  JFlow.configuration.logger.debug "Registering domain #{domain_name}"
  JFlow.configuration.swf_client.register_domain({
    name: domain_name,
    description: domain_name,
    workflow_execution_retention_period_in_days: "90"
  })
end

#exists?Boolean

Returns:

  • (Boolean)


20
21
22
23
24
25
26
27
28
29
# File 'lib/jflow/domain.rb', line 20

def exists?
  domains = JFlow.configuration.swf_client.list_domains({
    registration_status: "REGISTERED"
  })
  exists = domains.domain_infos
                  .map{|a| a.name}
                  .include?(domain_name)
  JFlow.configuration.logger.debug "#{domain_name} found: #{exists}"
  exists
end