Sha256: e1871ba88cd971e0173729a3364cb975b823f9c50a8cae7d8e0bef953f7c1d89

Contents?: true

Size: 644 Bytes

Versions: 6

Compression:

Stored size: 644 Bytes

Contents

module Reel
  class Request
    # Tracks the state of Reel requests
    class StateMachine
      include Celluloid::FSM

      def initialize(socket)
        @socket   = socket
        @hijacked = false
      end

      default_state :headers

      state :headers, :to => [:body, :hijacked, :closed]
      state :body,    :to => [:headers, :closed]

      state :hijacked do
        @hijacked = true
      end

      # FSM fails open for valid transitions
      # Set an empty array to disallow transitioning out of closed
      state :closed, :to => [] do
        @socket.close unless @hijacked || @socket.closed?
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
reel-0.6.1 lib/reel/request/state_machine.rb
reel-0.6.0 lib/reel/request/state_machine.rb
reel-0.6.0.pre5 lib/reel/request/state_machine.rb
reel-0.6.0.pre4 lib/reel/request/state_machine.rb
reel-0.6.0.pre3 lib/reel/request/state_machine.rb
reel-0.6.0.pre2 lib/reel/request/state_machine.rb