Sha256: 69ae56a3105947d5af05c988633005dbeb56a247049a933d684e9db24f0feff3
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
require 'populus/remote_runner' require 'populus/node' module Populus class Accepter # TODO: validators class Base attr_accessor :condition, :runner, :metadata def initialize(cond: nil, runs: nil, metadata: {}) self.condition = cond self.runner = runs self.metadata = metadata end def type?(t) current_type = self.class.name.downcase .split('::') .last current_type == t end def accept(data) if condition[data] Populus.logger.debug "Condition judged true: #{data.inspect}" instance_exec(data, &runner) return true else Populus.logger.debug "Condition judged false: #{data.inspect}" return false end end def on(hostname, &run_it) be = Node.registory[hostname] if be RemoteRunner.new(be, &run_it) else Populus.logger.warn "Not found host: #{hostname}. Skip." end end end class Event < Base def has_name?(name) metadata[:name] == name end def create_thread _name = metadata[:name] Populus.logger.debug "Create thread: consul watch -type event -name #{_name}" Populus::WatchThread.consul_watch('-type', 'event', '-name', _name) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
populus-0.0.3 | lib/populus/accepter.rb |