class CottonTail::Queue::Reader
Public Class Methods
new(queue, app:)
click to toggle source
# File lib/cotton_tail/queue/reader.rb, line 13 def initialize(queue, app:) @queue = queue @app = app end
spawn(queue, **kwargs)
click to toggle source
# File lib/cotton_tail/queue/reader.rb, line 9 def self.spawn(queue, **kwargs) Thread.new { new(queue, **kwargs).start } end
Public Instance Methods
fiber()
click to toggle source
# File lib/cotton_tail/queue/reader.rb, line 18 def fiber @fiber ||= Fiber.new do Fiber.yield @queue.pop until @queue.empty? && @queue.closed? end end
start()
click to toggle source
# File lib/cotton_tail/queue/reader.rb, line 24 def start call_next while fiber.alive? end
Private Instance Methods
call_next()
click to toggle source
# File lib/cotton_tail/queue/reader.rb, line 30 def call_next request = fiber.resume middleware.call([env, request, Response.new]) if request end
env()
click to toggle source
# File lib/cotton_tail/queue/reader.rb, line 39 def env @app.env end
middleware()
click to toggle source
# File lib/cotton_tail/queue/reader.rb, line 35 def middleware @app.config.middleware end