Sha256: 3edb13a0ee5ada5f6af820431a77b6f00430469518d156c55787607b4f1f4ebf
Contents?: true
Size: 1.45 KB
Versions: 2
Compression:
Stored size: 1.45 KB
Contents
module Legion::Extensions::Health module Runners module Health include Legion::Extensions::Helpers::Lex def update(hostname:, **opts) item = Legion::Data::Model::Node[name: hostname] return { success: insert(hostname: hostname, **opts), hostname: hostname, **opts } if item.nil? if opts.key?(:timestamp) && !item.values[:updated].nil? && item.values[:updated] > Time.parse(opts[:timestamp]) return { success: false, reason: 'entry already updated', hostname: hostname, db_updated: item.values[:updated], **opts } end { success: item.update(active: 1, status: opts[:status], name: hostname, updated: Sequel::CURRENT_TIMESTAMP), hostname: hostname, **opts } end def insert(hostname:, status: 'unknown', **opts) insert = { active: 1, status: status, name: hostname } insert[:datacenter_id] = opts[:datacenter_id] if opts.key? :datacenter_id insert[:environment_id] = opts[:environment_id] if opts.key? :environment_id insert[:active] = opts[:active] if opts.key? :active { success: true, hostname: hostname, node_id: Legion::Data::Model::Node.insert(insert), **insert } end def delete(node_id:, **_opts) Legion::Data::Model::Node[node_id].delete { success: true, node_id: node_id } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lex-health-0.1.4 | lib/legion/extensions/health/runners/health.rb |
lex-health-0.1.3 | lib/legion/extensions/health/runners/health.rb |