Class: EcsDeployer::Service::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/ecs_deployer/service/client.rb

Constant Summary collapse

LOG_SEPARATOR =
'-' * 96

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cluster, logger, aws_options = {}) ⇒ EcsDeployer::Service::Client

Parameters:

  • (defaults to: {})


14
15
16
17
18
19
20
21
22
23
# File 'lib/ecs_deployer/service/client.rb', line 14

def initialize(cluster, logger, aws_options = {})
  @cluster = cluster
  @logger = logger

  @ecs = Aws::ECS::Client.new(aws_options)
  @task = EcsDeployer::Task::Client.new(aws_options)

  @wait_timeout = 900
  @polling_interval = 20
end

Instance Attribute Details

#polling_intervalObject

Returns the value of attribute polling_interval.



8
9
10
# File 'lib/ecs_deployer/service/client.rb', line 8

def polling_interval
  @polling_interval
end

#wait_timeoutObject

Returns the value of attribute wait_timeout.



8
9
10
# File 'lib/ecs_deployer/service/client.rb', line 8

def wait_timeout
  @wait_timeout
end

Instance Method Details

#update(service, task_definition = nil, wait = true) ⇒ Aws::ECS::Types::Service

Parameters:

  • (defaults to: nil)

Returns:



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ecs_deployer/service/client.rb', line 28

def update(service, task_definition = nil, wait = true)
  task_definition = @task.register_clone(@cluster, service) if task_definition.nil?
  result = @ecs.update_service(
    cluster: @cluster,
    service: service,
    task_definition: task_definition[:family] + ':' + task_definition[:revision].to_s
  )

  wait_for_deploy(service, result.service.task_definition) if wait
  result.service
end