Git Product home page Git Product logo

rack-esi's Introduction

rack-esi

Rack-ESI is a Nokogiri based ESI middleware implementation for Rack with support for include tags, all other ESI namespaced nodes are just removed.

To make this gem work you must define the xmlns:esi namespace in your text/html response.

Note: This gem should only be used in development. For production use setup varnish or any other ESI enabled server.

Features

  • threaded (in case we have slow IOs)
  • PATH_INFO blacklisting (:skip => nil, should respond to ===)
  • support for esi|include[alt] and esi|include[noerror] fallbacks

Dependencies

  • Nokogiri
  • Rack

Setup

w/o Gemfile

$ gem install rack-esi

w/ Gemfile

gem 'rack-esi'

... and ...

$ bundle

rackup

use Rack::ESI, options || {}
run Application.new

Rails 2.3: environment.rb

... for setups w/o Gemfile

config.gem 'rack-esi'

... and ...

config.middleware.insert Rack::Lock, Rack::ESI

Rails 3.x: application.rb

config.middleware.insert ActionDispatch::Static, Rack::ESI

Rails 4.x: config/environments/development.rb

config.middleware.insert_before Rack::Lock, Rack::ESI

Options

  • poolsize: 4, Number of worker threads. A value of 1 disables threading model.
  • skip: nil, This should be an object which responds to #===(PATH_INFO).
  • parser: Nokogiri::XML::Document, You can change this to Nokogiri::HTML::Document, but you should change the serializer, too (see below).
  • serializer: :to_xhtml, The serializer value specifies the method name which is send to the object created by the parser#parse.

TODO

  • write documentation
  • write more tests
  • support more ESI elements

Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it.
  • Commit, do not mess with rakefile, version, or history.
  • Send me a pull request.

Thanks

tenderlove and Qerub

Copyright

Copyright (c) 2011 Florian Aßmann. See LICENSE for details.

rack-esi's People

Contributors

boof avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rack-esi's Issues

No live threads left. Deadlock? error

I'm trying to get this middleware running on Rails 4 w/ Unicorn as the web server. When I load a page with a single ESI tag I get the following:

Should I be using a different web server in development for this to work? Any help would be appreciated.

23:30:45 web.1 | Finishing #<Rack::ESI::Worker:0x007fe342778760 run>...
23:30:45 web.1 | Finishing #<Rack::ESI::Worker:0x007fe342778a80 run>...
23:30:45 web.1 | Finishing #<Rack::ESI::Worker:0x007fe342783ea8 run>...
23:30:45 web.1 | /Users/harlow/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-esi-0.2.0/lib/rack-esi/threaded.rb:46:in stop': No live threads left. Deadlock? from /Users/harlow/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-esi-0.2.0/lib/rack-esi/threaded.rb:46:inprocess_document'
23:30:45 web.1 | from /Users/harlow/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-esi-0.2.0/lib/rack-esi/processor.rb:48:in process' 23:30:45 web.1 | from /Users/harlow/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-esi-0.2.0/lib/rack-esi.rb:39:incall'
23:30:45 web.1 | from /Users/harlow/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/sendfile.rb:112:in call' 23:30:45 web.1 | from /Users/harlow/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/engine.rb:516:incall'
23:30:45 web.1 | from /Users/harlow/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/application.rb:142:in call' 23:30:45 web.1 | from /Users/harlow/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/lint.rb:49:in_call'
23:30:45 web.1 | from /Users/harlow/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/lint.rb:37:in call' 23:30:45 web.1 | from /Users/harlow/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/showexceptions.rb:24:incall'
23:30:45 web.1 | from /Users/harlow/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/commonlogger.rb:33:in call' 23:30:45 web.1 | from /Users/harlow/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/chunked.rb:43:incall'
23:30:45 web.1 | from /Users/harlow/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/content_length.rb:14:in call' 23:30:45 web.1 | from /Users/harlow/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:580:inprocess_client'
23:30:45 web.1 | from /Users/harlow/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:660:in worker_loop' 23:30:45 web.1 | from /Users/harlow/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:527:inspawn_missing_workers'
23:30:45 web.1 | from /Users/harlow/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:153:in start' 23:30:45 web.1 | from /Users/harlow/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/unicorn-4.7.0/bin/unicorn:126:in<top (required)>'
23:30:45 web.1 | from /Users/harlow/.rbenv/versions/2.0.0-p247/bin/unicorn:23:in load' 23:30:45 web.1 | from /Users/harlow/.rbenv/versions/2.0.0-p247/bin/unicorn:23:in

'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.