Class: RollCall::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/roll_call/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, serviceName, url) ⇒ Node

Returns a new instance of Node.



8
9
10
11
12
# File 'lib/roll_call/node.rb', line 8

def initialize(name,serviceName,url)
  @name = name
  @serviceName = serviceName
  @url = url + '/services/' + @serviceName + '/nodes/'    
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/roll_call/node.rb', line 6

def name
  @name
end

#serviceNameObject

Returns the value of attribute serviceName.



6
7
8
# File 'lib/roll_call/node.rb', line 6

def serviceName
  @serviceName
end

#statusObject

Returns the value of attribute status.



6
7
8
# File 'lib/roll_call/node.rb', line 6

def status
  @status
end

#urlObject

Returns the value of attribute url.



6
7
8
# File 'lib/roll_call/node.rb', line 6

def url
  @url
end

Instance Method Details

#registerObject



14
15
16
17
# File 'lib/roll_call/node.rb', line 14

def register
  payload = {service_node:{"name" => @name}}
  RestClient.post(@url,payload, content_type: :json, accept: :json)
end

#unregisterObject



19
20
21
# File 'lib/roll_call/node.rb', line 19

def unregister
  RestClient.delete(@url + @name)
end

#update(level, info) ⇒ Object



23
24
25
26
27
# File 'lib/roll_call/node.rb', line 23

def update(level,info)
  @extension = '/status'
  payload = {node_statu:{info:info, level:level}} 
  RestClient.put(@url + @name + @extension ,payload.to_json,content_type: :json, accept: :json)
end