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.



8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
# File 'lib/models/porcelain.rb', line 8083

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



8067
8068
8069
# File 'lib/models/porcelain.rb', line 8067

def error_msg
  @error_msg
end

#healthyObject

Whether the healthcheck succeeded.



8069
8070
8071
# File 'lib/models/porcelain.rb', line 8069

def healthy
  @healthy
end

#idObject

Unique identifier of the healthcheck.



8071
8072
8073
# File 'lib/models/porcelain.rb', line 8071

def id
  @id
end

#node_idObject

Unique identifier of the healthcheck node.



8073
8074
8075
# File 'lib/models/porcelain.rb', line 8073

def node_id
  @node_id
end

#node_nameObject

The name of the node.



8075
8076
8077
# File 'lib/models/porcelain.rb', line 8075

def node_name
  @node_name
end

#resource_idObject

Unique identifier of the healthcheck resource.



8077
8078
8079
# File 'lib/models/porcelain.rb', line 8077

def resource_id
  @resource_id
end

#resource_nameObject

The name of the resource.



8079
8080
8081
# File 'lib/models/porcelain.rb', line 8079

def resource_name
  @resource_name
end

#timestampObject

The time at which the healthcheck state was recorded.



8081
8082
8083
# File 'lib/models/porcelain.rb', line 8081

def timestamp
  @timestamp
end

Instance Method Details

#to_json(options = {}) ⇒ Object



8103
8104
8105
8106
8107
8108
8109
# File 'lib/models/porcelain.rb', line 8103

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