Class: SDM::Healthcheck

Inherits:
Object
  • Object
show all
Defined in:
lib/models/porcelain.rb

Overview

Healthcheck defines the status of the link between a node and a resource

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error_msg: nil, healthy: nil, id: nil, node_id: nil, node_name: nil, resource_id: nil, resource_name: nil, timestamp: nil) ⇒ Healthcheck

Returns a new instance of Healthcheck.



5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
# File 'lib/models/porcelain.rb', line 5745

def initialize(
  error_msg: nil,
  healthy: nil,
  id: nil,
  node_id: nil,
  node_name: nil,
  resource_id: nil,
  resource_name: nil,
  timestamp: nil
)
  @error_msg = error_msg == nil ? "" : error_msg
  @healthy = healthy == nil ? false : healthy
  @id = id == nil ? "" : id
  @node_id = node_id == nil ? "" : node_id
  @node_name = node_name == nil ? "" : node_name
  @resource_id = resource_id == nil ? "" : resource_id
  @resource_name = resource_name == nil ? "" : resource_name
  @timestamp = timestamp == nil ? nil : timestamp
end

Instance Attribute Details

#error_msgObject

The error if unhealthy



5729
5730
5731
# File 'lib/models/porcelain.rb', line 5729

def error_msg
  @error_msg
end

#healthyObject

Whether the healthcheck succeeded.



5731
5732
5733
# File 'lib/models/porcelain.rb', line 5731

def healthy
  @healthy
end

#idObject

Unique identifier of the healthcheck.



5733
5734
5735
# File 'lib/models/porcelain.rb', line 5733

def id
  @id
end

#node_idObject

Unique identifier of the healthcheck node.



5735
5736
5737
# File 'lib/models/porcelain.rb', line 5735

def node_id
  @node_id
end

#node_nameObject

The name of the node.



5737
5738
5739
# File 'lib/models/porcelain.rb', line 5737

def node_name
  @node_name
end

#resource_idObject

Unique identifier of the healthcheck resource.



5739
5740
5741
# File 'lib/models/porcelain.rb', line 5739

def resource_id
  @resource_id
end

#resource_nameObject

The name of the resource.



5741
5742
5743
# File 'lib/models/porcelain.rb', line 5741

def resource_name
  @resource_name
end

#timestampObject

The time at which the healthcheck state was recorded.



5743
5744
5745
# File 'lib/models/porcelain.rb', line 5743

def timestamp
  @timestamp
end

Instance Method Details

#to_json(options = {}) ⇒ Object



5765
5766
5767
5768
5769
5770
5771
# File 'lib/models/porcelain.rb', line 5765

def to_json(options = {})
  hash = {}
  self.instance_variables.each do |var|
    hash[var.id2name.delete_prefix("@")] = self.instance_variable_get var
  end
  hash.to_json
end