Class: Marathon::DeploymentInfo

Inherits:
Base
  • Object
show all
Defined in:
lib/marathon/deployment_info.rb

Overview

This class represents a Marathon Deployment information. It is returned by asynchronious deployment calls.

Constant Summary collapse

RECHECK_INTERVAL =
3

Instance Attribute Summary

Attributes inherited from Base

#info

Instance Method Summary collapse

Methods inherited from Base

#to_json

Methods included from Error

error_class, error_message, from_response

Constructor Details

#initialize(hash, marathon_instance = Marathon.singleton) ⇒ DeploymentInfo

Create a new deployment info object. hash: Hash returned by API, including ‘deploymentId’ and ‘version’ marathon_instance: MarathonInstance holding a connection to marathon



10
11
12
13
14
# File 'lib/marathon/deployment_info.rb', line 10

def initialize(hash, marathon_instance = Marathon.singleton)
  super(hash, %w[deploymentId version])
  raise Marathon::Error::ArgumentError, 'version must not be nil' unless version
  @marathon_instance = marathon_instance
end

Instance Method Details

#to_sObject



28
29
30
31
32
33
34
# File 'lib/marathon/deployment_info.rb', line 28

def to_s
  if deploymentId
    "Marathon::DeploymentInfo { :version => #{version} :deploymentId => #{deploymentId} }"
  else
    "Marathon::DeploymentInfo { :version => #{version} }"
  end
end

#wait(timeout = 60) ⇒ Object

Wait for a deployment to finish. timeout: Timeout in seconds.



18
19
20
21
22
23
24
25
26
# File 'lib/marathon/deployment_info.rb', line 18

def wait(timeout = 60)
  Timeout::timeout(timeout) do
    deployments = nil
    while deployments.nil? or deployments.any? { |e| e.id == deploymentId } do
      sleep(RECHECK_INTERVAL)
      deployments = @marathon_instance.deployments.list
    end
  end
end