Sha256: e615903c7436b763a15ae6033403f85824653e6abc8856e8431bdc03b1a595c1

Contents?: true

Size: 1.54 KB

Versions: 26

Compression:

Stored size: 1.54 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/middleware/cache'
require 'routemaster/middleware/expire_cache'
require 'routemaster/drain/terminator'
require 'rack/builder'
require 'delegate'

module Routemaster
  module Drain
    # Rack application which authenticates, parses, filters, pushes to a dirty map,
    # busts cache, schedules preemptive caching, and finally broadcasts events
    # received from Routemaster.
    #
    # See the various corresponding middleware for details on operation:
    # {Middleware::RootPostOnly}, {Middleware::Authenticate},
    # {Middleware::Parse}, {Middleware::Filter}, {Middleware::Dirty},
    # {Middleware::Cache} and {Terminator}.
    #
    class Caching
      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::ExpireCache,  options
          use Middleware::Siphon,       options
          use Middleware::Filter,       options
          use Middleware::Dirty,        options
          use Middleware::Cache,        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.7.1 lib/routemaster/drain/caching.rb
routemaster-drain-3.7.0 lib/routemaster/drain/caching.rb
routemaster-drain-3.6.8 lib/routemaster/drain/caching.rb
routemaster-drain-3.6.7 lib/routemaster/drain/caching.rb
routemaster-drain-3.6.6 lib/routemaster/drain/caching.rb
routemaster-drain-3.6.5 lib/routemaster/drain/caching.rb
routemaster-drain-3.6.4 lib/routemaster/drain/caching.rb
routemaster-drain-3.6.3 lib/routemaster/drain/caching.rb
routemaster-drain-3.6.2 lib/routemaster/drain/caching.rb
routemaster-drain-3.6.1 lib/routemaster/drain/caching.rb
routemaster-drain-3.6.0 lib/routemaster/drain/caching.rb
routemaster-drain-3.5.1 lib/routemaster/drain/caching.rb
routemaster-drain-3.5.0 lib/routemaster/drain/caching.rb
routemaster-drain-3.4.0 lib/routemaster/drain/caching.rb
routemaster-drain-3.3.0 lib/routemaster/drain/caching.rb
routemaster-drain-3.2.0 lib/routemaster/drain/caching.rb
routemaster-drain-3.1.0 lib/routemaster/drain/caching.rb
routemaster-drain-3.0.3 lib/routemaster/drain/caching.rb
routemaster-drain-3.0.2 lib/routemaster/drain/caching.rb
routemaster-drain-3.0.1 lib/routemaster/drain/caching.rb