Sha256: 6ca2e059a82c9d23bad625ddd5544a90403eb798f442b92ea95c0ad849d762c8

Contents?: true

Size: 590 Bytes

Versions: 7

Compression:

Stored size: 590 Bytes

Contents

# frozen_string_literal: true

require 'fiber'

module CottonTail
  module Queue
    # A supervisor for a single queue
    class Supervisor
      def initialize(queue, app:)
        @queue = queue
        @app = app
      end

      def start
        process
      end

      # Start the supervisor, process all pending messages, and then stop
      def run
        @queue.close
        start.tap(&:join)
      end

      def running?
        true & process.status
      end

      private

      def process
        @process ||= Reader.spawn(@queue, app: @app)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cotton-tail-0.7.0 lib/cotton_tail/queue/supervisor.rb
cotton-tail-0.6.1 lib/cotton_tail/queue/supervisor.rb
cotton-tail-0.6.0 lib/cotton_tail/queue/supervisor.rb
cotton-tail-0.5.0 lib/cotton_tail/queue/supervisor.rb
cotton-tail-0.4.1 lib/cotton_tail/queue/supervisor.rb
cotton-tail-0.4.0 lib/cotton_tail/queue/supervisor.rb
cotton-tail-0.3.0 lib/cotton_tail/queue/supervisor.rb