<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -19,12 +19,15 @@ Following snippet will invoke method @some_task@ with argument @data@ in @foo_wo
 be invoked asychrounously and Rails won't wait for result from BackgrounDRb server.
 
 &lt;pre class=&quot;multiline&quot;&gt;worker = MiddleMan.worker(:foo_worker)
-worker.some_task(data,false) &lt;/pre&gt;
+worker.some_task(data) &lt;/pre&gt;
+
+Here, I would like to illustrate  a point that contrary to general percenption, since @some_task@ method is being
+executed asyhcrounously, don't expect any meaningful return values from second line.
 
 When you invoke @MiddleMan.worker(:foo_worker)@ it returns a worker proxy, hence you can combine above two lines in
 one as follows:
 
-&lt;pre class=&quot;boxed&quot;&gt;MiddleMan.worker(:foo_worker,&lt;optional_job_key&gt;).some_task(data,false) &lt;/pre&gt;
+&lt;pre class=&quot;boxed&quot;&gt;MiddleMan.worker(:foo_worker,&lt;optional_job_key&gt;).some_task(data) &lt;/pre&gt;
 
 Above snippet also demonstrates that, if your worker was started with a @job_key@ you can use it to
 get correct proper worker proxy.
@@ -35,9 +38,11 @@ Following snippet will invoke method @some_task@ with argument @data@ in @foo_wo
 until BackgrounDRb server returns a result.
 
 &lt;pre class=&quot;multiline&quot;&gt;worker = MiddleMan.worker(:foo_worker)
-result = worker.some_task(data,false) &lt;/pre&gt;
+result = worker.some_task(data,true) &lt;/pre&gt;
 
-As illustrated above, you can use @job_key@ or make them in single line too. 
+As illustrated above, you can use @job_key@ or make them in single line too. When you are invoking a method
+on your worker first optional argument will be passed to your worker method and second optional argument @true|false@
+indicates whether we should wait for result from _BackgrounDRb_ server or not.
 
 p(sub-title). Fetch Status/Result Objects of a worker :
 
@@ -52,11 +57,45 @@ p(sub-title). Start a Worker :
 
 To start a worker from rails:
 
-&lt;pre class=&quot;boxed&quot;&gt;MiddleMan.new_worker(:foo_worker,&quot;my_secret_job_key&quot;) &lt;/pre&gt;
+&lt;pre class=&quot;multiline&quot;&gt;used_job_key = MiddleMan.new_worker(:worker =&gt; :foo_worker,\
+     :job_key =&gt; &quot;my_secret_job_key&quot;) &lt;/pre&gt;
+
+@new_worker@ will always return @job_key@ generated for the worker. It will be same as @job_key@ passed while creating the
+worker and can be reused to invoke further tasks on the same worker or for deleting the worker.
 
 Important thing to be kept in mind is, when you are creating a worker using above approach, you
 must use a unique @job_key@ while starting the worker. Also, while invoking any of the other methods
 like @ask_status@, @worker_info@ or one of the worker methods, you must use @job_key@.
 
+Also another complicated example of starting a worker will be:
+
+&lt;pre class=&quot;multiline&quot;&gt;MiddleMan.new_worker(:worker =&gt; :error_worker, :job_key =&gt; :hello_world,\
+     :data =&gt; &quot;wow_man&quot;,:schedule =&gt; \
+     { :hello_world =&gt; { :trigger_args =&gt; &quot;*/5 * * * * * *&quot;,\
+     :data =&gt; &quot;hello_world&quot; }}) &lt;/pre&gt;
+
+Above code will start @error_worker@ with @job_key@ and will pass argument @:data@ to @create@
+method of the worker. Worker will be scheduled to run @hello_world@ method every 5 seconds with argument 
+specified in @:data@.
+
+p(sub-title). Worker Statistics:
+
+You can get worker specific information using:
+
+&lt;pre class=&quot;boxed&quot;&gt;MiddleMan.worker(:foo_worker).worker_info &lt;/pre&gt;
+
+The return value will look something like:
+
+&lt;pre class=&quot;boxed&quot;&gt;{:worker=&gt;:foo_worker, :status=&gt;:running, :job_key=&gt;&quot;hello&quot;} &lt;/pre&gt;
+
+Information about all currently running workers can be obtained using:
+
+&lt;pre class=&quot;boxed&quot;&gt;MiddleMan.all_worker_info &lt;/pre&gt;
+
+Return value will look like:
+&lt;pre class=&quot;multiline&quot;&gt;[{:worker=&gt;:foo_worker, :status=&gt;:running, :job_key=&gt;&quot;hello&quot;}, \
+     {:worker=&gt;:foo_worker, :status=&gt;:running, :job_key=&gt;&quot;&quot;}] &lt;/pre&gt;
+
+
 
 &lt;/div&gt;</diff>
      <filename>doc/content/rails/rails.txt</filename>
    </modified>
    <modified>
      <diff>@@ -2,6 +2,34 @@
 
 %(entry-title)&lt;a name=&quot;introduction&quot;&gt; Introduction &lt;/a&gt;%     
 
-Workers are your building blocks of Asynchronous Task Processing.
+Workers are your building blocks of Asynchronous Task Processing. An empty auto generated worker looks like this:
+
+&lt;pre class=&quot;multiline&quot;&gt;class BillingWorker &lt; BackgrounDRb::MetaWorker
+  set_worker_name :billing_worker
+  def create(args = nil)
+    # method gets called, when new instance of worker is created.                      
+   end
+  end &lt;/pre&gt;
+
+@set_worker_name@ will set the worker name which can be later used while invoking tasks on the worker.
+@create@ method gets called when worker is loaded for the first time. If you are starting your worker 
+from rails, you can pass arguments to @create@ method using:
+
+&lt;pre class=&quot;multiline&quot;&gt;MiddleMan.new_worker(:worker =&gt; :billing_worker,\
+     :job_key =&gt; user_session,:data =&gt; current_user.id) &lt;/pre&gt;
+
+p(sub-title). Using Workers
+
+You can invoke random tasks on workers from rails or you can schedule them using config file. Look into
+&quot;Scheduling&quot;:/scheduling/index.html section for scheduling and &quot;Rails Integration&quot;:/rails/index.html section
+for invoking worker tasks from rails.
+
+p(sub-title). Inbuilt instance methods available in your workers:
+
+*(content_list) @register_status@ : Can be used to store random results from worker which can be later retrieved from rails. For example:
+  &lt;pre class=&quot;boxed&quot;&gt; register_status(&quot;Hello&quot;) &lt;/pre&gt;
+* @add_timer@
+* @add_periodic_timer@
+* @thread_pool@
 
 &lt;/div&gt;</diff>
      <filename>doc/content/workers/workers.txt</filename>
    </modified>
    <modified>
      <diff>@@ -78,13 +78,17 @@ be invoked asychrounously and Rails won&amp;#8217;t wait for result from BackgrounDR
 
 
 &lt;pre class=&quot;multiline&quot;&gt;worker = MiddleMan.worker(:foo_worker)
-worker.some_task(data,false) &lt;/pre&gt;
+worker.some_task(data) &lt;/pre&gt;
+
+	&lt;p&gt;Here, I would like to illustrate  a point that contrary to general percenption, since &lt;code&gt;some_task&lt;/code&gt; method is being
+executed asyhcrounously, don&amp;#8217;t expect any meaningful return values from second line.&lt;/p&gt;
+
 
 	&lt;p&gt;When you invoke &lt;code&gt;MiddleMan.worker(:foo_worker)&lt;/code&gt; it returns a worker proxy, hence you can combine above two lines in
 one as follows:&lt;/p&gt;
 
 
-&lt;pre class=&quot;boxed&quot;&gt;MiddleMan.worker(:foo_worker,&amp;lt;optional_job_key&amp;gt;).some_task(data,false) &lt;/pre&gt;
+&lt;pre class=&quot;boxed&quot;&gt;MiddleMan.worker(:foo_worker,&amp;lt;optional_job_key&amp;gt;).some_task(data) &lt;/pre&gt;
 
 	&lt;p&gt;Above snippet also demonstrates that, if your worker was started with a &lt;code&gt;job_key&lt;/code&gt; you can use it to
 get correct proper worker proxy.&lt;/p&gt;
@@ -98,9 +102,11 @@ until BackgrounDRb server returns a result.&lt;/p&gt;
 
 
 &lt;pre class=&quot;multiline&quot;&gt;worker = MiddleMan.worker(:foo_worker)
-result = worker.some_task(data,false) &lt;/pre&gt;
+result = worker.some_task(data,true) &lt;/pre&gt;
 
-	&lt;p&gt;As illustrated above, you can use &lt;code&gt;job_key&lt;/code&gt; or make them in single line too.&lt;/p&gt;
+	&lt;p&gt;As illustrated above, you can use &lt;code&gt;job_key&lt;/code&gt; or make them in single line too. When you are invoking a method
+on your worker first optional argument will be passed to your worker method and second optional argument &lt;code&gt;true|false&lt;/code&gt;
+indicates whether we should wait for result from &lt;em&gt;BackgrounDRb&lt;/em&gt; server or not.&lt;/p&gt;
 
 
 	&lt;p class=&quot;sub-title&quot;&gt;Fetch Status/Result Objects of a worker :&lt;/p&gt;
@@ -121,13 +127,53 @@ rails using:&lt;/p&gt;
 	&lt;p&gt;To start a worker from rails:&lt;/p&gt;
 
 
-&lt;pre class=&quot;boxed&quot;&gt;MiddleMan.new_worker(:foo_worker,&quot;my_secret_job_key&quot;) &lt;/pre&gt;
+&lt;pre class=&quot;multiline&quot;&gt;used_job_key = MiddleMan.new_worker(:worker =&amp;gt; :foo_worker,\
+     :job_key =&amp;gt; &quot;my_secret_job_key&quot;) &lt;/pre&gt;
+
+	&lt;p&gt;&lt;code&gt;new_worker&lt;/code&gt; will always return &lt;code&gt;job_key&lt;/code&gt; generated for the worker. It will be same as &lt;code&gt;job_key&lt;/code&gt; passed while creating the
+worker and can be reused to invoke further tasks on the same worker or for deleting the worker.&lt;/p&gt;
+
 
 	&lt;p&gt;Important thing to be kept in mind is, when you are creating a worker using above approach, you
 must use a unique &lt;code&gt;job_key&lt;/code&gt; while starting the worker. Also, while invoking any of the other methods
 like &lt;code&gt;ask_status&lt;/code&gt;, &lt;code&gt;worker_info&lt;/code&gt; or one of the worker methods, you must use &lt;code&gt;job_key&lt;/code&gt;.&lt;/p&gt;
 
 
+	&lt;p&gt;Also another complicated example of starting a worker will be:&lt;/p&gt;
+
+
+&lt;pre class=&quot;multiline&quot;&gt;MiddleMan.new_worker(:worker =&amp;gt; :error_worker, :job_key =&amp;gt; :hello_world,\
+     :data =&amp;gt; &quot;wow_man&quot;,:schedule =&amp;gt; \
+     { :hello_world =&amp;gt; { :trigger_args =&amp;gt; &quot;*/5 * * * * * *&quot;,\
+     :data =&amp;gt; &quot;hello_world&quot; }}) &lt;/pre&gt;
+
+	&lt;p&gt;Above code will start &lt;code&gt;error_worker&lt;/code&gt; with &lt;code&gt;job_key&lt;/code&gt; and will pass argument &lt;code&gt;:data&lt;/code&gt; to &lt;code&gt;create&lt;/code&gt;
+method of the worker. Worker will be scheduled to run &lt;code&gt;hello_world&lt;/code&gt; method every 5 seconds with argument 
+specified in &lt;code&gt;:data&lt;/code&gt;.&lt;/p&gt;
+
+
+	&lt;p class=&quot;sub-title&quot;&gt;Worker Statistics:&lt;/p&gt;
+
+
+	&lt;p&gt;You can get worker specific information using:&lt;/p&gt;
+
+
+&lt;pre class=&quot;boxed&quot;&gt;MiddleMan.worker(:foo_worker).worker_info &lt;/pre&gt;
+
+	&lt;p&gt;The return value will look something like:&lt;/p&gt;
+
+
+&lt;pre class=&quot;boxed&quot;&gt;{:worker=&amp;gt;:foo_worker, :status=&amp;gt;:running, :job_key=&amp;gt;&quot;hello&quot;} &lt;/pre&gt;
+
+	&lt;p&gt;Information about all currently running workers can be obtained using:&lt;/p&gt;
+
+
+&lt;pre class=&quot;boxed&quot;&gt;MiddleMan.all_worker_info &lt;/pre&gt;
+
+Return value will look like:
+&lt;pre class=&quot;multiline&quot;&gt;[{:worker=&amp;gt;:foo_worker, :status=&amp;gt;:running, :job_key=&amp;gt;&quot;hello&quot;}, \
+     {:worker=&amp;gt;:foo_worker, :status=&amp;gt;:running, :job_key=&amp;gt;&quot;&quot;}] &lt;/pre&gt;
+
 &lt;/div&gt;
 
       &lt;div id=&quot;footer&quot;&gt;</diff>
      <filename>doc/output/rails/index.html</filename>
    </modified>
    <modified>
      <diff>@@ -52,7 +52,42 @@
 	&lt;p&gt;&lt;span class=&quot;entry-title&quot;&gt;&lt;a name=&quot;introduction&quot;&gt; Introduction &lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
 
 
-	&lt;p&gt;Workers are your building blocks of Asynchronous Task Processing.&lt;/p&gt;
+	&lt;p&gt;Workers are your building blocks of Asynchronous Task Processing. An empty auto generated worker looks like this:&lt;/p&gt;
+
+
+&lt;pre class=&quot;multiline&quot;&gt;class BillingWorker &amp;lt; BackgrounDRb::MetaWorker
+  set_worker_name :billing_worker
+  def create(args = nil)
+    # method gets called, when new instance of worker is created.                      
+   end
+  end &lt;/pre&gt;
+
+	&lt;p&gt;&lt;code&gt;set_worker_name&lt;/code&gt; will set the worker name which can be later used while invoking tasks on the worker.
+&lt;code&gt;create&lt;/code&gt; method gets called when worker is loaded for the first time. If you are starting your worker 
+from rails, you can pass arguments to &lt;code&gt;create&lt;/code&gt; method using:&lt;/p&gt;
+
+
+&lt;pre class=&quot;multiline&quot;&gt;MiddleMan.new_worker(:worker =&amp;gt; :billing_worker,\
+     :job_key =&amp;gt; user_session,:data =&amp;gt; current_user.id) &lt;/pre&gt;
+
+	&lt;p class=&quot;sub-title&quot;&gt;Using Workers&lt;/p&gt;
+
+
+	&lt;p&gt;You can invoke random tasks on workers from rails or you can schedule them using config file. Look into
+&lt;a href=&quot;/scheduling/index.html&quot;&gt;Scheduling&lt;/a&gt; section for scheduling and &lt;a href=&quot;/rails/index.html&quot;&gt;Rails Integration&lt;/a&gt; section
+for invoking worker tasks from rails.&lt;/p&gt;
+
+
+	&lt;p class=&quot;sub-title&quot;&gt;Inbuilt instance methods available in your workers:&lt;/p&gt;
+
+
+	&lt;ul class=&quot;content_list&quot;&gt;
+	&lt;li&gt;&lt;code&gt;register_status&lt;/code&gt; : Can be used to store random results from worker which can be later retrieved from rails. For example:
+  &lt;pre class=&quot;boxed&quot;&gt; register_status(&quot;Hello&quot;) &lt;/pre&gt;&lt;/li&gt;
+		&lt;li&gt;&lt;code&gt;add_timer&lt;/code&gt;&lt;/li&gt;
+		&lt;li&gt;&lt;code&gt;add_periodic_timer&lt;/code&gt;&lt;/li&gt;
+		&lt;li&gt;&lt;code&gt;thread_pool&lt;/code&gt;&lt;/li&gt;
+	&lt;/ul&gt;
 
 
 &lt;/div&gt;</diff>
      <filename>doc/output/workers/index.html</filename>
    </modified>
    <modified>
      <diff>@@ -16,7 +16,9 @@ MiddleMan.worker(:foo_worker).some_work(&quot;hello World&quot;)
 MiddleMan.new_worker(:worker =&gt; :foo_worker, :job_key =&gt; &quot;wow&quot;,:data =&gt; &quot;Hello World&quot;)
 
 # new API
-worker = MiddelMan.new_worker(:foo_worker,:job_key =&gt; &quot;Wow&quot;)
+worker = MiddelMan.new_worker(:foo_worker,:job_key =&gt; &quot;Wow&quot;,:data =&gt; &quot;Wow man&quot;,\
+                              :schedule =&gt; { :hello_world =&gt; { :trigger_args =&gt; &quot;*/5 * * * * * *&quot;,:data =&gt; &quot;hello_world&quot; }})
+
 worker.hello_world(&quot;Wow man&quot;)
 worker.delete
 </diff>
      <filename>examples/clean_api.rb</filename>
    </modified>
    <modified>
      <diff>@@ -22,6 +22,10 @@ class BackgrounDRb::WorkerProxy
     @mutex = Mutex.new
     establish_connection
   end
+  
+  def worker(worker_name,job_key = nil)
+    BackgrounDRb::RailsWorkerProxy.worker(worker_name,job_key)
+  end
 
   def establish_connection
     begin
@@ -71,6 +75,7 @@ class BackgrounDRb::WorkerProxy
   end
   
   def dump_object data
+    p data
     unless @connection_status
       establish_connection
       raise BackgrounDRb::BdrbConnError.new(&quot;Error while connecting to the backgroundrb server&quot;) unless @connection_status</diff>
      <filename>lib/backgroundrb.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,31 +9,36 @@ module BackgrounDRb
     end
     
     def method_missing(method_id,*args)
-      @worker_method = method_id
-      @data = args[0]
+      worker_method = method_id
+      p worker_method
+      
+      data = args[0]
+      
+      p data
+      
       flag = args[1]
-      case @worker_method
+      
+      p flag
+      
+      case worker_method
       when :ask_status
-        if job_key 
-          MiddleMan.ask_status(:worker =&gt; worker_name,:job_key =&gt; job_key)
-        else
-          MiddleMan.ask_status(:worker =&gt; worker_name)
-        end
+        MiddleMan.ask_status(compact(:worker =&gt; worker_name,:job_key =&gt; job_key))
       when :worker_info
-    
-      when :all_worker_info
-        
-      when :new_worker
-        
+        MiddleMan.worker_info(compact(:worker =&gt; worker_name,:job_key =&gt; job_key))
       when :delete
-        
+        MiddleMan.delete_worker(compact(:worker =&gt; worker_name, :job_key =&gt; job_key))
       else
-        
-        
+        if flag
+          MiddleMan.send_request(compact(:worker =&gt; worker_name,:job_key =&gt; job_key,:worker_method =&gt; worker_method,:data =&gt; data))
+        else
+          MiddleMan.ask_work(compact(:worker =&gt; worker_name,:job_key =&gt; job_key,:worker_method =&gt; worker_method,:data =&gt; data))
+        end
       end
     end
     
-    def pack_modifers(p_option = { })
+    def compact(options = { })
+      options.delete_if { |key,value| value.nil? }
+      options
     end
 
     </diff>
      <filename>lib/backgroundrb/rails_worker_proxy.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>9f4a7726962233dbe0665422be80a7b68ffcd62c</id>
    </parent>
  </parents>
  <author>
    <name>gnufied</name>
    <email>mail@gnufied.org</email>
  </author>
  <url>http://github.com/georgepalmer/backgroundrb_merb/commit/ec5226be22def1cab45e6e185481b43a21d8504a</url>
  <id>ec5226be22def1cab45e6e185481b43a21d8504a</id>
  <committed-date>2008-02-27T02:27:40-08:00</committed-date>
  <authored-date>2008-02-27T02:27:40-08:00</authored-date>
  <message>Fixed new API and updated documentation</message>
  <tree>9b22cd4d322652e125da8f83fab4b2f406834602</tree>
  <committer>
    <name>gnufied</name>
    <email>mail@gnufied.org</email>
  </committer>
</commit>
