Class: Marathon::Leader

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

Overview

This class represents a Marathon Leader. See mesosphere.github.io/marathon/docs/rest-api.html#get-/v2/leader for full list of API’s methods.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(marathon_instance = Marathon.singleton) ⇒ Leader

Returns a new instance of Leader.



5
6
7
# File 'lib/marathon/leader.rb', line 5

def initialize(marathon_instance = Marathon.singleton)
  @connection = marathon_instance.connection
end

Class Method Details

.deleteObject

Causes the current leader to abdicate, triggering a new election. If no leader exists, raises NotFoundError.



30
31
32
# File 'lib/marathon/leader.rb', line 30

def delete
  Marathon.singleton.leaders.delete
end

.getObject

Returns the current leader. If no leader exists, raises NotFoundError.



24
25
26
# File 'lib/marathon/leader.rb', line 24

def get
  Marathon.singleton.leaders.get
end

Instance Method Details

#deleteObject

Causes the current leader to abdicate, triggering a new election. If no leader exists, raises NotFoundError.



17
18
19
20
# File 'lib/marathon/leader.rb', line 17

def delete
  json = @connection.delete('/v2/leader')
  json['message']
end

#getObject

Returns the current leader. If no leader exists, raises NotFoundError.



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

def get
  json = @connection.get('/v2/leader')
  json['leader']
end