about summary refs log tree commit homepage
path: root/lib/raindrops.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-04-07 17:07:42 -0700
committerEric Wong <normalperson@yhbt.net>2010-04-07 17:36:31 -0700
commitc3e9f5ba6fc10397f55941f36da29808a105d248 (patch)
tree705970f479064931ae07cfca0cd44013c113cb8d /lib/raindrops.rb
downloadraindrops-c3e9f5ba6fc10397f55941f36da29808a105d248.tar.gz
Diffstat (limited to 'lib/raindrops.rb')
-rw-r--r--lib/raindrops.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/raindrops.rb b/lib/raindrops.rb
new file mode 100644
index 0000000..693358a
--- /dev/null
+++ b/lib/raindrops.rb
@@ -0,0 +1,32 @@
+# -*- encoding: binary -*-
+class Raindrops
+
+  # Used to represent the number of +active+ and +queued+ sockets for
+  # a single listen socket across all threads and processes on a
+  # machine.
+  #
+  # For TCP listeners, only sockets in the TCP_ESTABLISHED state are
+  # accounted for.  For Unix domain listeners, only CONNECTING and
+  # CONNECTED Unix domain sockets are accounted for.
+  #
+  # +active+ connections is the number of accept()-ed but not-yet-closed
+  # sockets in all threads/processes sharing the given listener.
+  #
+  # +queued+ connections is the number of un-accept()-ed sockets in the
+  # queue of a given listen socket.
+  #
+  # These stats are currently only available under Linux
+  class ListenStats < Struct.new(:active, :queued)
+
+    # the sum of +active+ and +queued+ sockets
+    def total
+      active + queued
+    end
+  end
+
+  # TODO: pure Ruby version for single processes
+  require 'raindrops_ext'
+
+  autoload :Struct, 'raindrops/struct'
+  autoload :Middleware, 'raindrops/middleware'
+end