Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
Backport of the FutureResult => Future rename.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias committed Jul 8, 2011
1 parent 3047e41 commit eec25d7
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions clients/messaging/lib/torquebox/messaging/backgroundable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.

require 'torquebox/messaging/destination'
require 'torquebox/messaging/future_result'
require 'torquebox/messaging/future'

module TorqueBox
module Messaging
Expand Down Expand Up @@ -106,7 +106,7 @@ module Util
class << self
def publish_message(receiver, method, args, options = { })
queue = Queue.new(QUEUE_NAME)
future = FutureResult.new( queue )
future = Future.new( queue )
queue.publish({:receiver => receiver,
:future_id => future.correlation_id,
:future_queue => QUEUE_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

module TorqueBox
module Messaging
# A FutureResult encapsulates the result of a long running
# A Future encapsulates the result of a long running
# process, and is used in conjunction with a {FutureResponder}.
class FutureResult
class Future

# Returns the remote error (if any)
attr_reader :error
Expand All @@ -29,7 +29,7 @@ class FutureResult
# @param [TorqueBox::Messaging::Queue] response_queue The queue
# where response messages are to be received.
# @param [Hash] options Additional options
# @option options [String] :correlation_id (FutureResult.unique_id) The correlation_id used on
# @option options [String] :correlation_id (Future.unique_id) The correlation_id used on
# the messages to uniquely identify the call they are for.
# @option options [Integer] :default_result_timeout (30_000) The timeout
# used by default for the receive call. The processing must at
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
module TorqueBox
module Messaging
# A FutureResponder encapsulates sending the results of a long
# running process to a {FutureResult}.
# running process to a {Future}.
class FutureResponder

# @param [TorqueBox::Messaging::Queue] response_queue The queue
Expand Down
4 changes: 2 additions & 2 deletions clients/messaging/lib/torquebox/messaging/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

require 'torquebox/messaging/destination'
require 'torquebox/messaging/future_responder'
require 'torquebox/messaging/future_result'
require 'torquebox/messaging/future'

module TorqueBox
module Messaging
Expand All @@ -31,7 +31,7 @@ def self.queue_name

def self.async(method, payload = {}, options = {})
queue = Queue.new(queue_name)
future = FutureResult.new( queue )
future = Future.new( queue )
message = {
:method => method,
:payload => payload,
Expand Down
4 changes: 2 additions & 2 deletions clients/messaging/spec/backgroundable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def redefine_me; end
@queue = mock('queue')
@queue.stub(:publish)
TorqueBox::Messaging::Queue.stub(:new).and_return(@queue)
TorqueBox::Messaging::FutureResult.stub(:unique_id).and_return('1234')
TorqueBox::Messaging::Future.stub(:unique_id).and_return('1234')
end

it "should put a message on the queue" do
Expand All @@ -72,7 +72,7 @@ def redefine_me; end

it "should return a future" do
result = MyTestModel.new.an_async_action(nil, nil)
result.is_a?(TorqueBox::Messaging::FutureResult).should be_true
result.is_a?(TorqueBox::Messaging::Future).should be_true
end

it "should include the proper options in the message" do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
require 'torquebox/messaging/future_result'
require 'torquebox/messaging/future'

include TorqueBox::Messaging

class FutureResult
class Future
attr_writer :started
attr_writer :complete
attr_writer :error
attr_writer :result
end

describe TorqueBox::Messaging::FutureResult do
describe TorqueBox::Messaging::Future do

before(:each) do
@queue = mock( Queue )
@future = FutureResult.new( @queue )
@future = Future.new( @queue )
end

describe "#result" do
Expand Down
6 changes: 3 additions & 3 deletions clients/messaging/spec/task_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'torquebox/messaging/future_responder'
require 'torquebox/messaging/future_result'
require 'torquebox/messaging/future'
require 'torquebox/messaging/destination'
require 'torquebox/messaging/task'

Expand All @@ -18,7 +18,7 @@ def respond

describe '#async' do
before(:each) do
TorqueBox::Messaging::FutureResult.stub(:unique_id).and_return('1234')
TorqueBox::Messaging::Future.stub(:unique_id).and_return('1234')
@send_queue = mock('queue')
@send_queue.stub(:publish)
TorqueBox::Messaging::Queue.should_receive(:new).with(MyTestTask.queue_name).and_return(@send_queue)
Expand All @@ -39,7 +39,7 @@ def respond

it "should return a future" do
result = MyTestTask.async(:payload=)
result.is_a?(TorqueBox::Messaging::FutureResult).should be_true
result.is_a?(TorqueBox::Messaging::Future).should be_true
end
end

Expand Down
16 changes: 8 additions & 8 deletions docs/en-US/src/main/docbook/messaging.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ messaging:

<para>Any of the task's methods can be invoked asynchronously by
calling the task's class method, <function>async</function>, which
returns a <link linkend="messaging-futures">FutureResult</link> object
returns a <link linkend="messaging-futures">Future</link> object
that can be used to monitor the status of the task processing
and retrieve the final return value.</para>

Expand Down Expand Up @@ -1330,7 +1330,7 @@ tasks:
on any object asynchronously. You can mark a method to always execute
in the background, or send a method to the background on an ad hoc
basis. Backgrounded methods return a <link
linkend="messaging-futures">FutureResult</link> object
linkend="messaging-futures">Future</link> object
that can be used to monitor the status of the method invocation
and retrieve the final return value.</para>

Expand Down Expand Up @@ -1387,7 +1387,7 @@ User.always_background(:send_signup_notification)
<function>always_background</function>, you can background it at call
time with the <function>background</function> instance method.
A method called via <function>background</function> will also return
a <link linkend="messaging-futures">FutureResult</link> object
a <link linkend="messaging-futures">Future</link> object
that can be used to monitor the status of the method invocation
and retrieve the final return value.</para>

Expand Down Expand Up @@ -1527,12 +1527,12 @@ tasks:
<section id="messaging-futures">
<title>Future Objects</title>
<para>Both <function>Task.async</function> and methods backgrounded via
<classname>Backgroundable</classname> return <classname>FutureResult</classname>
<classname>Backgroundable</classname> return <classname>Future</classname>
objects that allow you to monitor the progress of the asynchronous
processing.</para>

<table>
<title>FutureResult instance methods</title>
<title>Future instance methods</title>
<tgroup cols="2">
<colspec align="left" />

Expand Down Expand Up @@ -1606,11 +1606,11 @@ tasks:
</table>

<section id="messaging-futures-status">
<title>Sending status notifications to the FutureResult from within the task</title>
<title>Sending status notifications to the Future from within the task</title>

<para>From within a task or backgrounded method invocation, you can send
a status notification to the <classname>FutureResult</classname> for this
call by using the <function>TorqueBox::Messaging::FutureResult.status=</function>
a status notification to the <classname>Future</classname> for this
call by using the <function>TorqueBox::Messaging::Future.status=</function>
method. The status can be any marshalable object, and its semantics are
defined by your application.</para>

Expand Down

0 comments on commit eec25d7

Please sign in to comment.