Sha256: e7ce47033d17c46f50946b51b5d2393ec7a297f933487e4567e68a1c8c599fb7

Contents?: true

Size: 628 Bytes

Versions: 2

Compression:

Stored size: 628 Bytes

Contents

module QPush
  module Server
    # The Heartbeat worker periodically updates the heart key.
    # The key is set with an expiry. This helps to indicate if the QPush server
    # is currently active.
    #
    class Heartbeat
      def initialize
        @done = false
      end

      # Starts our heartbeat process. This will run until instructed to stop.
      #
      def start
        until @done
          Server.redis { |c| c.setex(Server.keys.heart, 30, true) }
          sleep 15
        end
      end

      # Shutsdown our heartbeat process.
      #
      def shutdown
        @done = true
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
qpush-0.1.7 lib/qpush/server/heartbeat.rb
qpush-0.1.6 lib/qpush/server/heartbeat.rb