Class: RollCall::Node
- Inherits:
-
Object
- Object
- RollCall::Node
- Defined in:
- lib/roll_call/node.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#serviceName ⇒ Object
Returns the value of attribute serviceName.
-
#status ⇒ Object
Returns the value of attribute status.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(name, serviceName, url) ⇒ Node
constructor
A new instance of Node.
- #register ⇒ Object
- #unregister ⇒ Object
- #update(level, info) ⇒ Object
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
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/roll_call/node.rb', line 6 def name @name end |
#serviceName ⇒ Object
Returns the value of attribute serviceName.
6 7 8 |
# File 'lib/roll_call/node.rb', line 6 def serviceName @serviceName end |
#status ⇒ Object
Returns the value of attribute status.
6 7 8 |
# File 'lib/roll_call/node.rb', line 6 def status @status end |
#url ⇒ Object
Returns the value of attribute url.
6 7 8 |
# File 'lib/roll_call/node.rb', line 6 def url @url end |
Instance Method Details
#register ⇒ Object
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 |
#unregister ⇒ Object
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 |