Sha256: 880d27341f985a278090a07863c3218e83973864e72ad61ba15afa5207ca87d6

Contents?: true

Size: 957 Bytes

Versions: 3

Compression:

Stored size: 957 Bytes

Contents

require 'legion/transport/messages/node_health'

module Legion::Extensions::Health
  module Runners
    module Watchdog
      include Legion::Extensions::Helpers::Lex

      def expire(**_opts)
        nodes = []
        Legion::Data::Model::Node
          .where(status: 'healthy')
          .where(Sequel.lit('updated <= DATE_SUB(SYSDATE(), INTERVAL 60 SECOND)'))
          .where(active: true)
          .each do |node|
            Legion::Transport::Messages::NodeHealth.new(status:    'unknown',
                                                        node_id:   node.values[:id],
                                                        hostname:  node.values[:name],
                                                        timestamp: node.values[:updated]).publish
            nodes.push(node.values[:id])
          end
        log.debug("count: #{nodes.count}")
        { success: true, count: nodes.count, nodes: nodes }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lex-health-0.1.2 lib/legion/extensions/health/runners/watchdog.rb
lex-health-0.1.1 lib/legion/extensions/health/runners/watchdog.rb
lex-health-0.1.0 lib/legion/extensions/health/runners/watchdog.rb