rainbows.git  about / heads / tags
Unicorn for sleepy apps and slow clients
blob 40615ac5c74efd706f527c4bfe8a15632b6e667c 408 bytes (raw)
$ git show v0.95.1:lib/rainbows/rev/master.rb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 
# -*- encoding: binary -*-
# :enddoc:
require 'rainbows/rev'

module Rainbows

  module Rev
    class Master < ::Rev::AsyncWatcher

      def initialize(queue)
        super()
        @queue = queue
      end

      def <<(output)
        @queue << output
        signal
      end

      def on_signal
        client, response = @queue.pop
        client.response_write(response)
      end
    end
  end
end

git clone https://yhbt.net/rainbows.git