Class: Hako::Schedulers::EcsServiceDiscoveryServiceComparator

Inherits:
Object
  • Object
show all
Defined in:
lib/hako/schedulers/ecs_service_discovery_service_comparator.rb

Instance Method Summary collapse

Constructor Details

#initialize(expected_service) ⇒ EcsServiceDiscoveryServiceComparator

Returns a new instance of EcsServiceDiscoveryServiceComparator.

Parameters:

  • expected_service (Hash)


9
10
11
12
# File 'lib/hako/schedulers/ecs_service_discovery_service_comparator.rb', line 9

def initialize(expected_service)
  @expected_service = expected_service
  @schema = service_schema
end

Instance Method Details

#different?(actual_service) ⇒ Boolean

Parameters:

  • actual_service (Aws::ServiceDiscovery::Types::ServiceSummary)

Returns:

  • (Boolean)


16
17
18
# File 'lib/hako/schedulers/ecs_service_discovery_service_comparator.rb', line 16

def different?(actual_service)
  !@schema.same?(actual_service.to_h, @expected_service)
end

#dns_config_schemaObject (private)



29
30
31
32
33
# File 'lib/hako/schedulers/ecs_service_discovery_service_comparator.rb', line 29

def dns_config_schema
  Schema::Structure.new.tap do |struct|
    struct.member(:dns_records, Schema::UnorderedArray.new(dns_records_schema))
  end
end

#dns_records_schemaObject (private)



35
36
37
38
39
40
# File 'lib/hako/schedulers/ecs_service_discovery_service_comparator.rb', line 35

def dns_records_schema
  Schema::Structure.new.tap do |struct|
    struct.member(:ttl, Schema::Integer.new)
    struct.member(:type, Schema::String.new)
  end
end

#service_schemaObject (private)



22
23
24
25
26
27
# File 'lib/hako/schedulers/ecs_service_discovery_service_comparator.rb', line 22

def service_schema
  Schema::Structure.new.tap do |struct|
    struct.member(:description, Schema::Nullable.new(Schema::String.new))
    struct.member(:dns_config, dns_config_schema)
  end
end