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.



9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
# File 'lib/models/porcelain.rb', line 9134

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



9118
9119
9120
# File 'lib/models/porcelain.rb', line 9118

def error_msg
  @error_msg
end

#healthyObject

Whether the healthcheck succeeded.



9120
9121
9122
# File 'lib/models/porcelain.rb', line 9120

def healthy
  @healthy
end

#idObject

Unique identifier of the healthcheck.



9122
9123
9124
# File 'lib/models/porcelain.rb', line 9122

def id
  @id
end

#node_idObject

Unique identifier of the healthcheck node.



9124
9125
9126
# File 'lib/models/porcelain.rb', line 9124

def node_id
  @node_id
end

#node_nameObject

The name of the node.



9126
9127
9128
# File 'lib/models/porcelain.rb', line 9126

def node_name
  @node_name
end

#resource_idObject

Unique identifier of the healthcheck resource.



9128
9129
9130
# File 'lib/models/porcelain.rb', line 9128

def resource_id
  @resource_id
end

#resource_nameObject

The name of the resource.



9130
9131
9132
# File 'lib/models/porcelain.rb', line 9130

def resource_name
  @resource_name
end

#timestampObject

The time at which the healthcheck state was recorded.



9132
9133
9134
# File 'lib/models/porcelain.rb', line 9132

def timestamp
  @timestamp
end

Instance Method Details

#to_json(options = {}) ⇒ Object



9154
9155
9156
9157
9158
9159
9160
# File 'lib/models/porcelain.rb', line 9154

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