Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update internal middlewares/purpose table.
  • Loading branch information
lifo committed Jan 12, 2009
1 parent 2a00f72 commit 3bf2ee5
Show file tree
Hide file tree
Showing 6 changed files with 886 additions and 841 deletions.
1,630 changes: 815 additions & 815 deletions railties/doc/guides/html/active_record_querying.html

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions railties/doc/guides/html/authors.html
Expand Up @@ -241,11 +241,11 @@ <h1>About the Authors</h1>
<div class="sidebar-title">Cássio Marques</div>
<div class="paragraph"><p>Cássio Marques is a Brazilian software developer working with different programming languages such as Ruby, JavaScript, C++ and Java, as an independent consultant. He blogs at <a href="http://cassiomarques.wordpress.com">http://cassiomarques.wordpress.com</a>, which is mainly written in portuguese, but will soon get a new section for posts with english translation.</p></div>
</div></div>
<div class="sidebarblock" id="lifo">
<div class="sidebar-content">
<div class="sidebar-title">Pratik Naik</div>
<div class="paragraph"><p>Pratik Naik is an independent Ruby on Rails consultant and also a member of the <a href="http://rubyonrails.com/core">Rails core team</a>. He blogs semi-regularly at <a href="http://m.onkey.org">has_many :bugs, :through =&gt; :rails</a> and has an active <a href="http://twitter.com/lifo">twitter account</a> .</p></div>
</div></div>
<div class="sidebarblock" id="lifo">
<div class="sidebar-content">
<div class="sidebar-title">Pratik Naik</div>
<div class="paragraph"><p>Pratik Naik is an independent Ruby on Rails consultant and also a member of the <a href="http://rubyonrails.com/core">Rails core team</a>. He blogs semi-regularly at <a href="http://m.onkey.org">has_many :bugs, :through =&gt; :rails</a> and has an active <a href="http://twitter.com/lifo">twitter account</a> .</p></div>
</div></div>
</div>
</div>

Expand Down
6 changes: 3 additions & 3 deletions railties/doc/guides/html/index.html
Expand Up @@ -260,7 +260,7 @@ <h2>Models</h2>
</div></div>
<div class="sidebarblock">
<div class="sidebar-content">
<div class="sidebar-title"><a href="active_record_querying.html">Active Record Query Interface</a></div>
<div class="sidebar-title"><a href="active_record_querying.html">Active Record Query Interface</a></div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
Expand All @@ -269,7 +269,7 @@ <h2>Models</h2>
<td class="content"><a href="http://rails.lighthouseapp.com/projects/16213/tickets/16">Lighthouse Ticket</a></td>
</tr></table>
</div>
<div class="paragraph"><p>This guide covers the database query interface provided by Active Record.</p></div>
<div class="paragraph"><p>This guide covers the database query interface provided by Active Record.</p></div>
</div></div>
<h2>Views</h2>
<div class="sidebarblock">
Expand Down Expand Up @@ -349,7 +349,7 @@ <h2>Digging Deeper</h2>
<div class="sidebarblock">
<div class="sidebar-content">
<div class="sidebar-title"><a href="performance_testing.html">Performance Testing Rails Applications</a></div>
<div class="paragraph"><p>This guide covers ways to benchmark and profile your Rails application.</p></div>
<div class="paragraph"><p>This guide covers ways to benchmark and profile your Rails application.</p></div>
</div></div>
<div class="sidebarblock">
<div class="sidebar-content">
Expand Down
4 changes: 2 additions & 2 deletions railties/doc/guides/html/performance_testing.html
Expand Up @@ -574,7 +574,7 @@ <h3 id="_performance_test_environment">1.7. Performance Test Environment</h3>
<pre><tt>ActionController<span style="color: #990000">::</span>Base<span style="color: #990000">.</span>perform_caching <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">true</span></span>
ActiveSupport<span style="color: #990000">::</span>Dependencies<span style="color: #990000">.</span>mechanism <span style="color: #990000">=</span> <span style="color: #990000">:</span>require
Rails<span style="color: #990000">.</span>logger<span style="color: #990000">.</span>level <span style="color: #990000">=</span> ActiveSupport<span style="color: #990000">::</span>BufferedLogger<span style="color: #990000">::</span>INFO</tt></pre></div></div>
<div class="paragraph"><p>As <tt>ActionController::Base.perform_caching</tt> is set to <tt>true</tt>, performance tests will behave much as they do in the <tt>production</tt> environment.</p></div>
<div class="paragraph"><p>As <tt>ActionController::Base.perform_caching</tt> is set to <tt>true</tt>, performance tests will behave much as they do in the <tt>production</tt> environment.</p></div>
<h3 id="gc">1.8. Installing GC-Patched Ruby</h3>
<div class="paragraph"><p>To get the best from Rails performance tests, you need to build a special Ruby binary with some super powers - <a href="http://rubyforge.org/tracker/download.php/1814/7062/17676/3291/ruby186gc.patch">GC patch</a> for measuring GC Runs/Time and memory/object allocation.</p></div>
<div class="paragraph"><p>The process is fairly straight forward. If you&#8217;ve never compiled a Ruby binary before, follow these steps to build a ruby binary inside your home directory:</p></div>
Expand Down Expand Up @@ -879,7 +879,7 @@ <h2 id="_changelog">7. Changelog</h2>
<div class="ulist"><ul>
<li>
<p>
January 9, 2009: Complete rewrite by <a href="../authors.html#lifo">Pratik</a>
January 9, 2009: Complete rewrite by <a href="../authors.html#lifo">Pratik</a>
</p>
</li>
<li>
Expand Down
42 changes: 34 additions & 8 deletions railties/doc/guides/html/rails_on_rack.html
Expand Up @@ -233,6 +233,8 @@ <h2>Chapters</h2>

<li><a href="#_generating_a_metal_application">Generating a Metal Application</a></li>

<li><a href="#_execution_order">Execution Order</a></li>

</ul>
</li>
<li>
Expand Down Expand Up @@ -465,31 +467,31 @@ <h3 id="_internal_middleware_stack">3.2. Internal Middleware Stack</h3>
<tbody valign="top">
<tr>
<td align="left"><p class="table">ActionController::Lock</p></td>
<td align="left"><p class="table">Mutex</p></td>
<td align="left"><p class="table">Sets <tt>env["rack.multithread"]</tt> flag to <tt>true</tt> and wraps the application within a Mutex.</p></td>
</tr>
<tr>
<td align="left"><p class="table">ActionController::Failsafe</p></td>
<td align="left"><p class="table">Never fail</p></td>
<td align="left"><p class="table">Returns HTTP Status <tt>500</tt> to the client if an exception gets raised while dispatching.</p></td>
</tr>
<tr>
<td align="left"><p class="table">ActiveRecord::QueryCache</p></td>
<td align="left"><p class="table">Query caching</p></td>
<td align="left"><p class="table">Enable the Active Record query cache.</p></td>
</tr>
<tr>
<td align="left"><p class="table">ActionController::Session::CookieStore</p></td>
<td align="left"><p class="table">Query caching</p></td>
<td align="left"><p class="table">Uses the cookie based session store.</p></td>
</tr>
<tr>
<td align="left"><p class="table">ActionController::Session::MemCacheStore</p></td>
<td align="left"><p class="table">Query caching</p></td>
<td align="left"><p class="table">Uses the memcached based session store.</p></td>
</tr>
<tr>
<td align="left"><p class="table">ActiveRecord::SessionStore</p></td>
<td align="left"><p class="table">Query caching</p></td>
<td align="left"><p class="table">Uses the database based session store.</p></td>
</tr>
<tr>
<td align="left"><p class="table">ActionController::VerbPiggybacking</p></td>
<td align="left"><p class="table">_method hax</p></td>
<td align="left"><p class="table">Sets HTTP method based on <tt>_method</tt> parameter or <tt>env["HTTP_X_HTTP_METHOD_OVERRIDE"]</tt>.</p></td>
</tr>
</tbody>
</table>
Expand Down Expand Up @@ -571,6 +573,30 @@ <h3 id="_generating_a_metal_application">4.1. Generating a Metal Application</h3
<span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">end</span></span></tt></pre></div></div>
<div class="paragraph"><p>Metal applications are an optimization. You should make sure to <a href="http://weblog.rubyonrails.org/2008/12/20/performance-of-rails-metal">understand the related performance implications</a> before using it.</p></div>
<h3 id="_execution_order">4.2. Execution Order</h3>
<div class="paragraph"><p>All Metal Applications are executed by <tt>Rails::Rack::Metal</tt> middleware, which is a part of the <tt>ActionController::MiddlewareStack</tt> chain.</p></div>
<div class="paragraph"><p>Here&#8217;s the primary method responsible for running the Metal applications:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 2.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">def</span></span> call<span style="color: #990000">(</span>env<span style="color: #990000">)</span>
<span style="color: #009900">@metals</span><span style="color: #990000">.</span>keys<span style="color: #990000">.</span>each <span style="font-weight: bold"><span style="color: #0000FF">do</span></span> <span style="color: #990000">|</span>app<span style="color: #990000">|</span>
result <span style="color: #990000">=</span> app<span style="color: #990000">.</span>call<span style="color: #990000">(</span>env<span style="color: #990000">)</span>
<span style="font-weight: bold"><span style="color: #0000FF">return</span></span> result <span style="font-weight: bold"><span style="color: #0000FF">unless</span></span> result<span style="color: #990000">[</span><span style="color: #993399">0</span><span style="color: #990000">].</span>to_i <span style="color: #990000">==</span> <span style="color: #993399">404</span>
<span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
<span style="color: #009900">@app</span><span style="color: #990000">.</span>call<span style="color: #990000">(</span>env<span style="color: #990000">)</span>
<span style="font-weight: bold"><span style="color: #0000FF">end</span></span></tt></pre></div></div>
<div class="paragraph"><p>In the code above, <tt>@metals</tt> is an ordered ( alphabetical ) hash of metal applications. Due to the alphabetical ordering, <tt>aaa.rb</tt> will come before <tt>bbb.rb</tt> in the metal chain.</p></div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<img src="./images/icons/important.png" alt="Important" />
</td>
<td class="content">Metal applications cannot return the HTTP Status <tt>404</tt> to a client, as it is used for continuing the Metal chain execution. Please use normal Rails controllers or a custom middleware if returning <tt>404</tt> is a requirement.</td>
</tr></table>
</div>
</div>
<h2 id="_middlewares_and_rails">5. Middlewares and Rails</h2>
<div class="sectionbody">
Expand All @@ -581,7 +607,7 @@ <h2 id="_changelog">6. Changelog</h2>
<div class="ulist"><ul>
<li>
<p>
January 11, 2009: First version by <a href="../authors.html#lifo">Pratik</a>
January 11, 2009: First version by <a href="../authors.html#lifo">Pratik</a>
</p>
</li>
</ul></div>
Expand Down
35 changes: 27 additions & 8 deletions railties/doc/guides/source/rails_on_rack.txt
Expand Up @@ -136,13 +136,13 @@ use ActionController::VerbPiggybacking
[options="header"]
|==========================================================================================================
|Middleware |Purpose
|ActionController::Lock | Mutex
|ActionController::Failsafe | Never fail
|ActiveRecord::QueryCache | Query caching
|ActionController::Session::CookieStore | Query caching
|ActionController::Session::MemCacheStore | Query caching
|ActiveRecord::SessionStore | Query caching
|ActionController::VerbPiggybacking | _method hax
|ActionController::Lock | Sets +env["rack.multithread"]+ flag to +true+ and wraps the application within a Mutex.
|ActionController::Failsafe | Returns HTTP Status +500+ to the client if an exception gets raised while dispatching.
|ActiveRecord::QueryCache | Enable the Active Record query cache.
|ActionController::Session::CookieStore | Uses the cookie based session store.
|ActionController::Session::MemCacheStore | Uses the memcached based session store.
|ActiveRecord::SessionStore | Uses the database based session store.
|ActionController::VerbPiggybacking | Sets HTTP method based on +_method+ parameter or +env["HTTP_X_HTTP_METHOD_OVERRIDE"]+.
|==========================================================================================================

=== Customizing Internal Middleware Stack ===
Expand Down Expand Up @@ -228,9 +228,28 @@ end

Metal applications are an optimization. You should make sure to http://weblog.rubyonrails.org/2008/12/20/performance-of-rails-metal[understand the related performance implications] before using it.

== Middlewares and Rails ==
=== Execution Order ===

All Metal Applications are executed by +Rails::Rack::Metal+ middleware, which is a part of the +ActionController::MiddlewareStack+ chain.

Here's the primary method responsible for running the Metal applications:

[source, ruby]
----------------------------------------------------------------------------
def call(env)
@metals.keys.each do |app|
result = app.call(env)
return result unless result[0].to_i == 404
end
@app.call(env)
end
----------------------------------------------------------------------------

In the code above, +@metals+ is an ordered ( alphabetical ) hash of metal applications. Due to the alphabetical ordering, +aaa.rb+ will come before +bbb.rb+ in the metal chain.

IMPORTANT: Metal applications cannot return the HTTP Status +404+ to a client, as it is used for continuing the Metal chain execution. Please use normal Rails controllers or a custom middleware if returning +404+ is a requirement.

== Middlewares and Rails ==

== Changelog ==

Expand Down

0 comments on commit 3bf2ee5

Please sign in to comment.