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.



9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
# File 'lib/models/porcelain.rb', line 9184

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



9168
9169
9170
# File 'lib/models/porcelain.rb', line 9168

def error_msg
  @error_msg
end

#healthyObject

Whether the healthcheck succeeded.



9170
9171
9172
# File 'lib/models/porcelain.rb', line 9170

def healthy
  @healthy
end

#idObject

Unique identifier of the healthcheck.



9172
9173
9174
# File 'lib/models/porcelain.rb', line 9172

def id
  @id
end

#node_idObject

Unique identifier of the healthcheck node.



9174
9175
9176
# File 'lib/models/porcelain.rb', line 9174

def node_id
  @node_id
end

#node_nameObject

The name of the node.



9176
9177
9178
# File 'lib/models/porcelain.rb', line 9176

def node_name
  @node_name
end

#resource_idObject

Unique identifier of the healthcheck resource.



9178
9179
9180
# File 'lib/models/porcelain.rb', line 9178

def resource_id
  @resource_id
end

#resource_nameObject

The name of the resource.



9180
9181
9182
# File 'lib/models/porcelain.rb', line 9180

def resource_name
  @resource_name
end

#timestampObject

The time at which the healthcheck state was recorded.



9182
9183
9184
# File 'lib/models/porcelain.rb', line 9182

def timestamp
  @timestamp
end

Instance Method Details

#to_json(options = {}) ⇒ Object



9204
9205
9206
9207
9208
9209
9210
# File 'lib/models/porcelain.rb', line 9204

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