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.



8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
# File 'lib/models/porcelain.rb', line 8619

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



8603
8604
8605
# File 'lib/models/porcelain.rb', line 8603

def error_msg
  @error_msg
end

#healthyObject

Whether the healthcheck succeeded.



8605
8606
8607
# File 'lib/models/porcelain.rb', line 8605

def healthy
  @healthy
end

#idObject

Unique identifier of the healthcheck.



8607
8608
8609
# File 'lib/models/porcelain.rb', line 8607

def id
  @id
end

#node_idObject

Unique identifier of the healthcheck node.



8609
8610
8611
# File 'lib/models/porcelain.rb', line 8609

def node_id
  @node_id
end

#node_nameObject

The name of the node.



8611
8612
8613
# File 'lib/models/porcelain.rb', line 8611

def node_name
  @node_name
end

#resource_idObject

Unique identifier of the healthcheck resource.



8613
8614
8615
# File 'lib/models/porcelain.rb', line 8613

def resource_id
  @resource_id
end

#resource_nameObject

The name of the resource.



8615
8616
8617
# File 'lib/models/porcelain.rb', line 8615

def resource_name
  @resource_name
end

#timestampObject

The time at which the healthcheck state was recorded.



8617
8618
8619
# File 'lib/models/porcelain.rb', line 8617

def timestamp
  @timestamp
end

Instance Method Details

#to_json(options = {}) ⇒ Object



8639
8640
8641
8642
8643
8644
8645
# File 'lib/models/porcelain.rb', line 8639

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