Sha256: 2f75499112ca6657b88c002326f0d3dba58a84a21f79192d207a11bbef08116e

Contents?: true

Size: 630 Bytes

Versions: 2

Compression:

Stored size: 630 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.10 lib/qpush/server/heartbeat.rb
qpush-0.1.8 lib/qpush/server/heartbeat.rb