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.



7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
# File 'lib/models/porcelain.rb', line 7131

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



7115
7116
7117
# File 'lib/models/porcelain.rb', line 7115

def error_msg
  @error_msg
end

#healthyObject

Whether the healthcheck succeeded.



7117
7118
7119
# File 'lib/models/porcelain.rb', line 7117

def healthy
  @healthy
end

#idObject

Unique identifier of the healthcheck.



7119
7120
7121
# File 'lib/models/porcelain.rb', line 7119

def id
  @id
end

#node_idObject

Unique identifier of the healthcheck node.



7121
7122
7123
# File 'lib/models/porcelain.rb', line 7121

def node_id
  @node_id
end

#node_nameObject

The name of the node.



7123
7124
7125
# File 'lib/models/porcelain.rb', line 7123

def node_name
  @node_name
end

#resource_idObject

Unique identifier of the healthcheck resource.



7125
7126
7127
# File 'lib/models/porcelain.rb', line 7125

def resource_id
  @resource_id
end

#resource_nameObject

The name of the resource.



7127
7128
7129
# File 'lib/models/porcelain.rb', line 7127

def resource_name
  @resource_name
end

#timestampObject

The time at which the healthcheck state was recorded.



7129
7130
7131
# File 'lib/models/porcelain.rb', line 7129

def timestamp
  @timestamp
end

Instance Method Details

#to_json(options = {}) ⇒ Object



7151
7152
7153
7154
7155
7156
7157
# File 'lib/models/porcelain.rb', line 7151

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