Class: KumoDockerCloud::Service
- Inherits:
-
Object
- Object
- KumoDockerCloud::Service
- Defined in:
- lib/kumo_dockercloud/service.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #check(checks, timeout) ⇒ Object
- #deploy(version) ⇒ Object
-
#initialize(stack_name, service_name) ⇒ Service
constructor
A new instance of Service.
- #links ⇒ Object
- #resource_uri ⇒ Object
- #set_link(service_to_link) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(stack_name, service_name) ⇒ Service
Returns a new instance of Service.
7 8 9 10 |
# File 'lib/kumo_dockercloud/service.rb', line 7 def initialize(stack_name, service_name) @stack_name = stack_name @name = service_name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/kumo_dockercloud/service.rb', line 5 def name @name end |
Instance Method Details
#check(checks, timeout) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/kumo_dockercloud/service.rb', line 17 def check(checks, timeout) Timeout::timeout(timeout) do all_tests_passed = true containers.each do |container| checks.each do |check| unless check.call(container) all_tests_passed = false end end end unless all_tests_passed print '.' sleep(5) check(checks, timeout) end true end rescue raise KumoDockerCloud::ServiceDeployError.new("One or more checks failed to pass within the timeout") end |
#deploy(version) ⇒ Object
12 13 14 15 |
# File 'lib/kumo_dockercloud/service.rb', line 12 def deploy(version) update_image(version) redeploy end |
#links ⇒ Object
40 41 42 |
# File 'lib/kumo_dockercloud/service.rb', line 40 def links get_service.linked_to_service.map { |service| KumoDockerCloud::Service.new(stack_name, service[:name]) } end |
#resource_uri ⇒ Object
58 59 60 |
# File 'lib/kumo_dockercloud/service.rb', line 58 def resource_uri get_service.resource_uri end |
#set_link(service_to_link) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/kumo_dockercloud/service.rb', line 44 def set_link(service_to_link) linked_service = { to_service: service_to_link.resource_uri, name: service_to_link.name, from_service: resource_uri } docker_cloud_api.services.update(uuid, linked_to_service: [linked_service]) end |
#stop ⇒ Object
54 55 56 |
# File 'lib/kumo_dockercloud/service.rb', line 54 def stop docker_cloud_api.services.stop(uuid) end |