Sha256: 062eeb2640681546afa562f0e79ddc3214ec7d787c9e42d9714acac604e07d63

Contents?: true

Size: 1.39 KB

Versions: 26

Compression:

Stored size: 1.39 KB

Contents

require 'routemaster/middleware/root_post_only'
require 'routemaster/middleware/authenticate'
require 'routemaster/middleware/parse'
require 'routemaster/middleware/siphon'
require 'routemaster/middleware/filter'
require 'routemaster/middleware/dirty'
require 'routemaster/drain/terminator'
require 'rack/builder'
require 'delegate'

module Routemaster
  module Drain
    # Rack application which authenticates, parses, filters, pushes to a dirty map,
    # and finally broadcasts events received from Routemaster.
    #
    # The dirty map can be obtained, for further processing, using
    # `Dirty::Map.new`.
    #
    # See the various corresponding middleware for details on operation:
    # {Middleware::RootPostOnly}, {Middleware::Authenticate},
    # {Middleware::Parse}, {Middleware::Filter}, {Middleware::Dirty},
    # and {Terminator}.
    #
    class Mapping
      extend Forwardable

      def initialize(options = {})
        @terminator = terminator = Terminator.new
        @app = ::Rack::Builder.new do
          use Middleware::RootPostOnly
          use Middleware::Authenticate, options
          use Middleware::Parse
          use Middleware::Siphon,       options
          use Middleware::Filter,       options
          use Middleware::Dirty,        options
          run terminator
        end
      end

      delegate :call => :@app
      delegate [:on, :subscribe] => :@terminator
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
routemaster-drain-3.0.0 lib/routemaster/drain/mapping.rb
routemaster-drain-2.5.4 lib/routemaster/drain/mapping.rb
routemaster-drain-2.5.3 lib/routemaster/drain/mapping.rb
routemaster-drain-2.5.2 lib/routemaster/drain/mapping.rb
routemaster-drain-2.5.1 lib/routemaster/drain/mapping.rb
routemaster-drain-2.5.0 lib/routemaster/drain/mapping.rb