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) ⇒ DeploymentInfo

Create a new deployment info object. hash: Hash returned by API, including ‘deploymentId’ and ‘version’



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

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

Instance Method Details

#to_sObject



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

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.



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

def wait(timeout = 60)
  Timeout::timeout(timeout) do
    deployments = nil
    while deployments.nil? or deployments.select{|e| e.id == deploymentId}.size > 0 do
      sleep(RECHECK_INTERVAL)
      deployments = Marathon::Deployment.list
    end
  end
end