about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-06-21 08:03:01 +0000
committerEric Wong <normalperson@yhbt.net>2010-06-21 08:03:01 +0000
commit23551fb5241630e1c8d1ea3788defb4b5bcbe832 (patch)
treeb7b6c8f14ae2d33c3fc2dc890e1ce7db51c3bba7
parentc9a573e669e62e824f8e3cf37cd94162cd7a4170 (diff)
downloadrainbows-23551fb5241630e1c8d1ea3788defb4b5bcbe832.tar.gz
Make it easier to link to the Rainbows! configuration
documentation without anchors.  This also reduces the
amount of code we spew into Unicorn::Configurator.
-rw-r--r--README4
-rw-r--r--lib/rainbows.rb38
-rw-r--r--lib/rainbows/configurator.rb46
3 files changed, 49 insertions, 39 deletions
diff --git a/README b/README
index 2650b3c..d16d3f4 100644
--- a/README
+++ b/README
@@ -133,8 +133,8 @@ config file:
       worker_connections 100
     end
 
-See the {Rainbows! configuration}[link:Rainbows.html#method-i-Rainbows!]
-{documentation}[link:Rainbows.html#method-i-Rainbows!]
+See the {Rainbows! configuration}[link:Rainbows/Configurator.html]
+{documentation}[link:Rainbows/Configurator.html]
 for more details.
 
 == Development
diff --git a/lib/rainbows.rb b/lib/rainbows.rb
index dd7cf1b..9e5b8a9 100644
--- a/lib/rainbows.rb
+++ b/lib/rainbows.rb
@@ -1,6 +1,7 @@
 # -*- encoding: binary -*-
 require 'unicorn'
 require 'rainbows/error'
+require 'rainbows/configurator'
 require 'fcntl'
 
 module Rainbows
@@ -95,40 +96,6 @@ module Rainbows
     def max_bytes=(nr); @@max_bytes = nr; end
   end
 
-  # configures \Rainbows! with a given concurrency model to +use+ and
-  # a +worker_connections+ upper-bound.  This method may be called
-  # inside a Unicorn/Rainbows configuration file:
-  #
-  #   Rainbows! do
-  #     use :Revactor # this may also be :ThreadSpawn or :ThreadPool
-  #     worker_connections 400
-  #     keepalive_timeout 0 # zero disables keepalives entirely
-  #     client_max_body_size 5*1024*1024 # 5 megabytes
-  #   end
-  #
-  #   # the rest of the Unicorn configuration
-  #   worker_processes 8
-  #
-  # See the documentation for the respective Revactor, ThreadSpawn,
-  # and ThreadPool classes for descriptions and recommendations for
-  # each of them.  The total number of clients we're able to serve is
-  # +worker_processes+ * +worker_connections+, so in the above example
-  # we can serve 8 * 400 = 3200 clients concurrently.
-  #
-  # The default is +keepalive_timeout+ is 5 seconds, which should be
-  # enough under most conditions for browsers to render the page and
-  # start retrieving extra elements for.  Increasing this beyond 5
-  # seconds is not recommended.  Zero disables keepalive entirely
-  # (but pipelining fully-formed requests is still works).
-  #
-  # The default +client_max_body_size+ is 1 megabyte (1024 * 1024 bytes),
-  # setting this to +nil+ will disable body size checks and allow any
-  # size to be specified.
-  def Rainbows!(&block)
-    block_given? or raise ArgumentError, "Rainbows! requires a block"
-    HttpServer.setup(block)
-  end
-
   # :stopdoc:
   # maps models to default worker counts, default worker count numbers are
   # pretty arbitrary and tuning them to your application and hardware is
@@ -172,6 +139,3 @@ module Rainbows
   end
 
 end
-
-# inject the Rainbows! method into Unicorn::Configurator
-Unicorn::Configurator.class_eval { include Rainbows }
diff --git a/lib/rainbows/configurator.rb b/lib/rainbows/configurator.rb
new file mode 100644
index 0000000..7add1f8
--- /dev/null
+++ b/lib/rainbows/configurator.rb
@@ -0,0 +1,46 @@
+# -*- encoding: binary -*-
+module Rainbows
+
+  # This module adds \Rainbows! to the
+  # {Unicorn::Configurator}[http://unicorn.bogomips.org/Unicorn/Configurator.html]
+  module Configurator
+
+    # configures \Rainbows! with a given concurrency model to +use+ and
+    # a +worker_connections+ upper-bound.  This method may be called
+    # inside a Unicorn/\Rainbows! configuration file:
+    #
+    #   Rainbows! do
+    #     use :ThreadSpawn # concurrency model to use
+    #     worker_connections 400
+    #     keepalive_timeout 0 # zero disables keepalives entirely
+    #     client_max_body_size 5*1024*1024 # 5 megabytes
+    #   end
+    #
+    #   # the rest of the Unicorn configuration
+    #   worker_processes 8
+    #
+    # See the documentation for the respective Revactor, ThreadSpawn,
+    # and ThreadPool classes for descriptions and recommendations for
+    # each of them.  The total number of clients we're able to serve is
+    # +worker_processes+ * +worker_connections+, so in the above example
+    # we can serve 8 * 400 = 3200 clients concurrently.
+    #
+    # The default is +keepalive_timeout+ is 5 seconds, which should be
+    # enough under most conditions for browsers to render the page and
+    # start retrieving extra elements for.  Increasing this beyond 5
+    # seconds is not recommended.  Zero disables keepalive entirely
+    # (but pipelining fully-formed requests is still works).
+    #
+    # The default +client_max_body_size+ is 1 megabyte (1024 * 1024 bytes),
+    # setting this to +nil+ will disable body size checks and allow any
+    # size to be specified.
+    def Rainbows!(&block)
+      block_given? or raise ArgumentError, "Rainbows! requires a block"
+      HttpServer.setup(block)
+    end
+
+  end
+end
+
+# inject the Rainbows! method into Unicorn::Configurator
+Unicorn::Configurator.class_eval { include Rainbows::Configurator }