From f4c1559078f0408375551964de73a892b8a6a9be Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Thu, 5 Jul 2012 14:00:13 +0100 Subject: Updated configuration for heartbeat to replace poll_every. Removed poll_every from other classes. Updated tests to reflect this. --- lib/mauve/configuration_builders/server.rb | 10 ---------- lib/mauve/heartbeat.rb | 17 ++++++++++++++--- lib/mauve/udp_server.rb | 2 -- 3 files changed, 14 insertions(+), 15 deletions(-) (limited to 'lib') diff --git a/lib/mauve/configuration_builders/server.rb b/lib/mauve/configuration_builders/server.rb index 734fb3b..ea12724 100644 --- a/lib/mauve/configuration_builders/server.rb +++ b/lib/mauve/configuration_builders/server.rb @@ -36,8 +36,6 @@ module Mauve is_attribute "port" # This is the IP address the server listens on. IPv6 is OK! e.g. [::] for all addresses is_attribute "ip" - # This is the sleep interval for the UDP server. - is_attribute "poll_every" # Sets up a Mauve::UDPServer singleton as the result # @@ -51,8 +49,6 @@ module Mauve # This is the thread that pulls packets from the queue for processing. # class Processor < ObjectBuilder - # This is the interval between polls of the packet queue. - is_attribute "poll_every" # This is the timeout for the transmission cache, which allows duplicate packets to be discarded. is_attribute "transmission_cache_expire_time" @@ -65,12 +61,6 @@ module Mauve end class Notifier < ObjectBuilder - # - # This is the interval at which the notification queue is polled for new - # notifications to be sent. This will not have any rate-limiting effect. - # - is_attribute "poll_every" - # Sets up a Mauve::Notifier singleton as the result # # @return [Mauve::Notifier] diff --git a/lib/mauve/heartbeat.rb b/lib/mauve/heartbeat.rb index 1fe2fab..11f4d5b 100644 --- a/lib/mauve/heartbeat.rb +++ b/lib/mauve/heartbeat.rb @@ -15,7 +15,7 @@ module Mauve # # Allow access to some basics. # - attr_reader :raise_after, :destination, :summary, :detail + attr_reader :raise_after, :destination, :summary, :detail, :send_every # # This sets up the Heartbeat singleton @@ -27,7 +27,7 @@ module Mauve @summary = "Mauve alert server heartbeat failed" @detail = "The Mauve server at #{Server.instance.hostname} has failed to send a heartbeat." @raise_after = 310 - @poll_every = 60 + @send_every = 60 end # @@ -38,8 +38,17 @@ module Mauve raise ArgumentError "raise_after must be an integer" unless i.is_a?(Integer) @raise_after = i end + + # + # This is the time period after which an alert is raised by the remote Mauve instance. + # @param [Integer] i Seconds + # @return [Integer] Seconds + def send_every=(i) + raise ArgumentError "send_every must be an integer" unless i.is_a?(Integer) + @send_every = i + end - alias send_every= poll_every= + alias poll_every= send_every= # Sets the summary of the heartbeat # @@ -97,6 +106,8 @@ module Mauve Mauve::Sender.new(self.destination).send(update) logger.debug "Sent to #{self.destination}" + + sleep @send_every end end diff --git a/lib/mauve/udp_server.rb b/lib/mauve/udp_server.rb index e3362e8..9dafdd0 100644 --- a/lib/mauve/udp_server.rb +++ b/lib/mauve/udp_server.rb @@ -22,7 +22,6 @@ module Mauve # Defaults: # * listening IP: 127.0.0.1 # * listening port: 32741 - # * polls every: 0 seconds # def initialize # @@ -30,7 +29,6 @@ module Mauve # self.ip = "127.0.0.1" self.port = 32741 - self.poll_every = 0 @socket = nil super -- cgit v1.2.1