From kato-k at rubyforge.org Tue Jun 5 07:29:38 2007 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Tue, 5 Jun 2007 07:29:38 -0400 (EDT) Subject: [ap4r-devel] [225] trunk/samples/HelloWorld/vendor/plugins/ap4r/lib: Moved and modified some comments to new api. Message-ID: <20070605112938.693B852409FE@rubyforge.org> Revision: 225 Author: kato-k Date: 2007-06-05 07:29:37 -0400 (Tue, 05 Jun 2007) Log Message: ----------- Moved and modified some comments to new api. Modified Paths: -------------- trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/ap4r_client.rb trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/async_helper.rb Modified: trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/ap4r_client.rb =================================================================== --- trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/ap4r_client.rb 2007-05-31 06:54:52 UTC (rev 224) +++ trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/ap4r_client.rb 2007-06-05 11:29:37 UTC (rev 225) @@ -6,6 +6,22 @@ require 'async_helper' module Ap4r + + # This +Client+ is the Rails plugin for asynchronous processing. + # Asynchronous logics are called via various protocols, such as XML-RPC, + # SOAP, HTTP POST, and more. Now default protocol is HTTP POST. + # + # Examples: The part of calling next asynchronous logics in a controller in the HelloWorld Sample. + # + # req = WorldRequest.new([:world_id => 1, :message => "World"}) + # ap4r.async_to({:controller => 'async_world', :action => 'execute'}, + # {:world_id => 1, :message => "World"}, + # {:dispatch_mode => :HTTP}) # skippable + # + # render :action => 'response' + # + # Complement: Above +ap4r+ method is defiend init.rb in +%RAILS_ROOT%/vendor/plugin/ap4r/+. + # class Client extend Forwardable include ::Ap4r::AsyncHelper::Base @@ -16,10 +32,100 @@ def_delegators :@controller, :logger, :url_for - # Alias for ::Ap4r::AsyncHelper::Base.async_dispatch + # Queue a message for next asynchronous logic. Some options are supported. + # + # Use options to specify target url, etc. + # Accurate meanings are defined by a individual converter class. + # * :controller (name of next logic) + # * :action (name of next logic) + # + # Use rm_options to pass parameter in queue-put. + # Listings below are AP4R extended options. + # See the reliable-msg docuememt for more details. + # * :target_url (URL of target, prevail over :controller) + # * :target_action (action of target, prevail over :action) + # * :target_method (HTTP method, e.g. "GET", "POST", etc.) + # * :dispatch_mode (protocol in dispatching) + # * :queue_name (prevail over :controller and :action) + # + # Object of argumemts (async_params, options and rm_options) will not be modified. + # Implementors (of this class and converters) should not modify them. + # + # Examples: the most simple + # + # ap4r.async_to({:controller => 'next_controller', :action => 'next_action'}, + # {:world_id => 1, :message => "World"}) + # + # + # Examples: taking block + # + # ap4r.async_to({:controller => 'next_controller', :action => 'next_action'}) do + # body :world_id, 1 + # body :message, "World" + # end + # + # + # Examples: transmitting ActiveRecord object + # + # ap4r.async_to({:controller => 'next_controller', :action => 'next_action'}) do + # body :world, World.find(1) + # body :message, "World" + # end + # + # + # Examples: transmitting with xml format over http (now support text, json and yaml format). + # + # ap4r.async_to({:controller => 'next_controller', :action => 'next_action'}) do + # body :world, World.find(1) + # body :message, "World" + # format :xml + # end + # + # + # Examples: direct assignment for formatted message body + # + # ap4r.async_to({:controller => 'next_controller', :action => 'next_action'}) do + # world = World.find(1).to_xml :except => ... + # body_as_xml world + # end + # + # + # Examples: setting message header + # + # ap4r.async_to({:controller => 'next_controller', :action => 'next_action'}) do + # body :world_id, 1 + # body :message, "World" + # + # header :priority, 1 + # http_header "Content-type", ... + # end + # alias :async_to :async_dispatch - # Alias for ::Ap4r::AsyncHelper::Base.transaction_with_saf + # Provides at-least-once QoS level. + # +block+ are tipically composed of database accesses and +async_to+ calls. + # Database accesses are executed transactionallly by +active_record_class+'s transaction method. + # In the +block+, +async_to+ calls invoke NOT immediate queueing but just storing messages + # to the database (assumed to be the same one as application uses). + # + # If the execution of +block+ finishes successfully, database transaction is committed and + # forward process of each stored message begins. + # Forward process composed in two parts. First puts the message into a queue, secondary update + # or delete the entry from a management table. + # + # SAF (store and forward) processing like this guarantees that any message + # is never lost and keeps reasonable performance (without two phase commit). + # + # Examples: Just call async_to method in this block. + # + # ap4r.transaction do + # req = WorldRequest.new([:world_id => 1, :message => "World"}) + # ap4r.async_to({:controller => 'async_world', :action => 'execute'}, + # {:world_id => 1, :message => "World"}) + # + # render :action => 'response' + # end + # alias :transaction :transaction_with_saf end Modified: trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/async_helper.rb =================================================================== --- trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/async_helper.rb 2007-05-31 06:54:52 UTC (rev 224) +++ trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/async_helper.rb 2007-06-05 11:29:37 UTC (rev 225) @@ -8,19 +8,9 @@ module Ap4r - # This +AsyncHelper+ is the Rails plugin for asynchronous processing. - # Asynchronous logics are called via various protocols, such as XML-RPC, - # SOAP, HTTP POST, and more. Now default protocol is HTTP POST. + # This +AsyncHelper+ is included to +Ap4rClient+ and works the Rails plugin + # for asynchronous processing. # - # Examples: The part of calling next asynchronous logics in a controller in the HelloWorld Sample. - # - # req = WorldRequest.new([:world_id => 1, :message => "World"}) - # async_dispatch(req, - # {:controller => 'async_world', :action => 'execute'}, - # :dispatch_mode => :XMLRPC }) # skippable - # - # render :action => 'response' - # module AsyncHelper module Base @@ -36,31 +26,8 @@ mattr_accessor :default_dispatch_mode, :default_rm_options, :default_queue_prefix, :saf_delete_mode - # Provides at-least-once QoS level. - # +block+ are tipically composed of database accesses and +async_dispatch+ calls. - # Database accesses are executed transactionallly by +active_record_class+'s transaction method. - # In the +block+, +async_dispatch+ calls invoke NOT immediate queueing but just storing messages - # to the database (assumed to be the same one as application uses). + # This method is aliased as ::Ap4r::Client#transaction # - # If the execution of +block+ finishes successfully, database transaction is committed and - # forward process of each stored message begins. - # Forward process composed in two parts. First puts the message into a queue, secondary update - # or delete the entry from a management table. - # - # SAF (store and forward) processing like this guarantees that any message - # is never lost and keeps reasonable performance (without two phase commit). - # - # Examples: Just call async_dispath method in this block. - # - # transaction_with saf do - # req = WorldRequest.new([:world_id => 1, :message => "World"}) - # async_dispatch(req, - # {:controller => 'async_world', :action => 'execute'}, - # :dispatch_mode => :XMLRPC }) # skippable - # - # render :action => 'response' - # end - # def transaction_with_saf(active_record_class = ::Ap4r::StoredMessage, *objects, &block) Thread.current[:use_saf] = true @@ -106,75 +73,6 @@ Thread.current[:stored_messages] = nil end - # Queue a message for next asynchronous logic. Some options are supported. - # - # Use options to specify target url, etc. - # Accurate meanings are defined by a individual converter class. - # * :controller (name of next logic) - # * :action (name of next logic) - # - # Use rm_options to pass parameter in queue-put. - # Listings below are AP4R extended options. - # See the reliable-msg docuememt for more details. - # * :target_url (URL of target, prevail over :controller) - # * :target_action (action of target, prevail over :action) - # * :target_method (HTTP method, e.g. "GET", "POST", etc.) - # * :dispatch_mode (protocol in dispatching) - # * :queue_name (prevail over :controller and :action) - # - # Object of argumemts (async_params, options and rm_options) will not be modified. - # Implementors (of this class and converters) should not modify them. - # - # Examples: the most simple - # - # async_dispatch({:controller => 'next_controller', :action => 'next_action'}, - # {:world_id => 1, :message => "World"}) - # - # - # Examples: taking block - # - # async_dispatch({:controller => 'next_controller', :action => 'next_action'}) do - # body :world_id, 1 - # body :message, "World" - # end - # - # - # Examples: transmitting ActiveRecord object - # - # async_dispatch({:controller => 'next_controller', :action => 'next_action'}) do - # body :world, World.find(1) - # body :message, "World" - # end - # - # - # Examples: transmitting with xml format over http (now support text, json and yaml format). - # - # async_dispatch({:controller => 'next_controller', :action => 'next_action'}) do - # body :world, World.find(1) - # body :message, "World" - # format :xml - # end - # - # - # Examples: direct assignment for formatted message body - # - # async_dispatch({:controller => 'next_controller', :action => 'next_action'}) do - # world = World.find(1).to_xml :except => ... - # body_as_xml world - # end - # - # - # Examples: setting message header - # - # async_dispatch({:controller => 'next_controller', :action => 'next_action'}) do - # body :world_id, 1 - # body :message, "World" - # - # header :priority, 1 - # http_header "Content-type", ... - # end - # - # # This method is aliased as ::Ap4r::Client#async_to # def async_dispatch(url_options = {}, async_params = {}, rm_options = {}, &block) From shino at rubyforge.org Tue Jun 5 22:55:05 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Tue, 5 Jun 2007 22:55:05 -0400 (EDT) Subject: [ap4r-devel] [226] trunk/ap4r/lib/ap4r: Adds rdoc. Message-ID: <20070606025505.84DEB5240A5E@rubyforge.org> Revision: 226 Author: shino Date: 2007-06-05 22:55:04 -0400 (Tue, 05 Jun 2007) Log Message: ----------- Adds rdoc. Modified Paths: -------------- trunk/ap4r/lib/ap4r/carrier.rb trunk/ap4r/lib/ap4r/dispatcher.rb trunk/ap4r/lib/ap4r/message_store_ext.rb trunk/ap4r/lib/ap4r/mongrel.rb trunk/ap4r/lib/ap4r/util/irm.rb Modified: trunk/ap4r/lib/ap4r/carrier.rb =================================================================== --- trunk/ap4r/lib/ap4r/carrier.rb 2007-06-05 11:29:37 UTC (rev 225) +++ trunk/ap4r/lib/ap4r/carrier.rb 2007-06-06 02:55:04 UTC (rev 226) @@ -10,10 +10,15 @@ require 'reliable-msg' module Ap4r + + # This class aims to balance loads of several reliable-msg servers. + # Only P2P channells (queues) are considered so far. + # Now reliable-msg can not be accessed from remote (means "not localhost"). + # Alpha status now. + #-- + # TODO: refactoring with dispatcher.rb, around thread group, etc. 2007/05/09 by shino class Carriers - # TODO: refactoring with dispatcher.rb, around thread group, etc. 2007/05/09 by shino - def initialize(queue_manager, config, logger, dispatchers) @qm = queue_manager @config = config Modified: trunk/ap4r/lib/ap4r/dispatcher.rb =================================================================== --- trunk/ap4r/lib/ap4r/dispatcher.rb 2007-06-05 11:29:37 UTC (rev 225) +++ trunk/ap4r/lib/ap4r/dispatcher.rb 2007-06-06 02:55:04 UTC (rev 226) @@ -132,8 +132,8 @@ end - # A base class for dispathcer classes. - # Responsibilities of subclasses is to implement following methods, only +invoke+ + # A base class for dispathcer classes associated with each dispatch_mode. + # Responsibilities of subclasses are to implement following methods, only +invoke+ # is mandatory and others are optional (no operations by default). # * +modify_message+ to preprocess a message, e.g. rewirte URL or discard message. # * +invoke+ to execute main logic, e.g. HTTP POST call. *mandatory* @@ -148,11 +148,18 @@ ::Ap4r::Dispatchers.register_dispatcher_class(mode_symbol, self) end + # Takes + # * +message+: from a queue + # * +conf+: configuration from dispatchers section + #-- + # TODO: Subclass should have +conf+ instead of instance? 2007/06/06 by shino def initialize(message, conf) @message = message @conf = conf end + # Entry facade for each message processing. + # Modifies, invokes (maybe remote), validates, and responds. def call # TODO: rename to more appropriate one 2007/05/10 by shino self.modify_message @@ -162,12 +169,16 @@ self.response end + # Modifies message. + # Now only URL modification is implemented. def modify_message modification_rules = @conf["modify_rules"] return unless modification_rules modify_url(modification_rules) end + # Main logic of message processing. + # Maybe calls remote, e.g. HTTP request. def invoke # TODO: rename to more appropriate one 2007/05/10 by shino raise 'must be implemented in subclasses' @@ -177,6 +188,9 @@ # nop end + # Returns response. + # The return value is also the return value of +call+ method. + # By default impl, the instance variable @response is used. def response @response end @@ -186,6 +200,8 @@ ::Ap4r::Dispatchers.logger end + # Modifies :target_url according to a rule. + # TODO: +proc+ in configuration is eval'ed every time. 2007/06/06 by shino def modify_url(modification_rules) proc_for_url = modification_rules["url"] return unless proc_for_url @@ -196,18 +212,18 @@ end end - # Dispatch logic via HTTP. + # Dispatches via a raw HTTP protocol. + # Current implementation uses only a POST method, irrespective of + # options[:target_method]. + # + # Determination of "success" is two fold: + # * status code should be exactly 200, other codes (including 201-2xx) are + # treated as error, and + # * body should include a string "true" + # class Http < Base dispatch_mode :HTTP - # Dispatches via a raw HTTP protocol. - # Current implementation uses only a POST method, irrespectively - # options[:target_method]. - # - # Determination of "success" is two fold: - # * status code should be exactly 200, other codes (including 201-2xx) are - # treated as error, and - # * body should include a string "true" def invoke # TODO: should be added some request headers 2006/10/12 shino # e.g. X-Ap4r-Version, Accept(need it?) @@ -267,6 +283,14 @@ end + # Dispatches via XML-RPC protocol. + # Uses +XMLRPC+ library. + # + # The call result is judged as + # * "failure" if the first element of XMLRPC::Client#call2 result + # is false, and + # * "success" otherwise. + # class XmlRpc < Base dispatch_mode :XMLRPC @@ -281,6 +305,13 @@ end end + # Dispatches via SOAP protocol. + # Uses +SOAP+ library. + # + # The call result is judged as + # * "success" if SOAP::WSDLDrive#send finishes without an exception, and + # * "failuar" otherwise. + # class SOAP < Base dispatch_mode :SOAP Modified: trunk/ap4r/lib/ap4r/message_store_ext.rb =================================================================== --- trunk/ap4r/lib/ap4r/message_store_ext.rb 2007-06-05 11:29:37 UTC (rev 225) +++ trunk/ap4r/lib/ap4r/message_store_ext.rb 2007-06-06 02:55:04 UTC (rev 226) @@ -2,8 +2,8 @@ # Copyright:: Copyright (c) 2007 Future Architect Inc. # Licence:: MIT Licence -module ReliableMsg - module MessageStore +module ReliableMsg #:nodoc: + module MessageStore #:nodoc: class Base cattr_accessor :use_mysql_extention @@ -37,11 +37,15 @@ end if ReliableMsg::MessageStore::Base.use_mysql_extention - class Mysql + class Mysql #:nodoc: alias original_query query + + # In Ruby/MySQL, +query+ method does NOT care about a given block. + # To make it behave the same as MySQL/Ruby, this method adds iteration + # over query results. def query(q, &block) maybe_result = original_query(q, &block) - puts "Mysql extention: query called by #{q}" + puts "Mysql extention: query called by #{q}" if $DEBUG puts "Mysql#query returns #{maybe_result}(class: #{maybe_result.class})." if $DEBUG return maybe_result unless block && maybe_result.kind_of?(Mysql::Result) begin Modified: trunk/ap4r/lib/ap4r/mongrel.rb =================================================================== --- trunk/ap4r/lib/ap4r/mongrel.rb 2007-06-05 11:29:37 UTC (rev 225) +++ trunk/ap4r/lib/ap4r/mongrel.rb 2007-06-06 02:55:04 UTC (rev 226) @@ -8,8 +8,10 @@ require 'ap4r' module Ap4r - module Mongrel + module Mongrel #:nodoc: + + # Gather controls AP4R server. class Ap4rConfigurator < ::Mongrel::Configurator def stop(needs_restart=false) @@ -39,6 +41,7 @@ # Implements a handler that can run AP4R. # * If the requested exact PATH_INFO exists as a file then serve it. + # + (Second, access server information or queue/topic API) NOT IMPLEMENTED. # * Finally, raise an exception. # # memo: want to use this handler to take information from AP4R server @@ -91,7 +94,7 @@ def reload! begin #TODO not implemented 2007/04/09 by shino - raise "not yet implemented!." + raise "not yet implemented!" end end Modified: trunk/ap4r/lib/ap4r/util/irm.rb =================================================================== --- trunk/ap4r/lib/ap4r/util/irm.rb 2007-06-05 11:29:37 UTC (rev 225) +++ trunk/ap4r/lib/ap4r/util/irm.rb 2007-06-06 02:55:04 UTC (rev 226) @@ -71,7 +71,7 @@ $original_main = self -class Object +class Object #:nodoc: Ap4r::Configuration.services.each {|s| module_eval <<-EOS def #{s.name.to_s} From shino at rubyforge.org Wed Jun 6 01:21:49 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Wed, 6 Jun 2007 01:21:49 -0400 (EDT) Subject: [ap4r-devel] [227] trunk/ap4r: Add rdoc. Message-ID: <20070606052149.B47805240BE4@rubyforge.org> Revision: 227 Author: shino Date: 2007-06-06 01:21:45 -0400 (Wed, 06 Jun 2007) Log Message: ----------- Add rdoc. Modified Paths: -------------- trunk/ap4r/CHANGELOG trunk/ap4r/lib/ap4r/queue_manager_ext.rb trunk/ap4r/lib/ap4r/queue_manager_ext_debug.rb trunk/ap4r/lib/ap4r/retention_history.rb trunk/ap4r/lib/ap4r/script/workspace_generator.rb trunk/ap4r/lib/ap4r/start_with_log4r.rb trunk/ap4r/lib/ap4r/store_and_forward.rb Modified: trunk/ap4r/CHANGELOG =================================================================== --- trunk/ap4r/CHANGELOG 2007-06-06 02:55:04 UTC (rev 226) +++ trunk/ap4r/CHANGELOG 2007-06-06 05:21:45 UTC (rev 227) @@ -1,9 +1,10 @@ == 0.3.x -=== 0.3.2 (? ?th, 2007) +=== 0.3.2 (June 7th, 2007) * Fixed: util/loc.rb doesn't work. * Changed: Argument order of async_dispatch has changed, backward INCOMPATIBLE. * Added: Dynamic configuration with ERb. +* Added: Script to run AP4R on Mongrel. === 0.3.1 (April 24th, 2007) @@ -14,7 +15,7 @@ === 0.3.0 (April 6th, 2007) * Changed: name space from "AP4R" to "Ap4r". -* Added: support the latest version for Rails(1.8.6) and RubyGems(0.9.2) and Rails(1.2.3) . +* Added: support the latest version for Ruby(1.8.6) and RubyGems(0.9.2) and Rails(1.2.3) . == 0.2.x Modified: trunk/ap4r/lib/ap4r/queue_manager_ext.rb =================================================================== --- trunk/ap4r/lib/ap4r/queue_manager_ext.rb 2007-06-06 02:55:04 UTC (rev 226) +++ trunk/ap4r/lib/ap4r/queue_manager_ext.rb 2007-06-06 05:21:45 UTC (rev 227) @@ -90,7 +90,6 @@ # Hooks original initialize method to add lifecyle listeners. #-- # TODO: Make dispatchers and carriers lifecyle listeners, 2006/09/01 shino - # TODO: and separate them from QueueManager, 2006/09/01 shino def initialize options = nil #:notnew: initialize_original options @global_lock ||= Mutex.new @@ -104,6 +103,13 @@ self.class.class_eval("attr_#{attr_mode} :#{iv_name}") end + # Starts reliable-msg server and something around it. + # + # Order is: + # 1. Original reliable-msg server (message store and druby). + # 2. Dispatchers + # 3. Carriors (if exists) + # These are Reversed in +stop+. def start begin @global_lock.synchronize do @@ -124,6 +130,8 @@ end end + # Stops reliable-msg server and something around it. + # See +start+ also. def stop @global_lock.synchronize do return unless @@active == self Modified: trunk/ap4r/lib/ap4r/queue_manager_ext_debug.rb =================================================================== --- trunk/ap4r/lib/ap4r/queue_manager_ext_debug.rb 2007-06-06 02:55:04 UTC (rev 226) +++ trunk/ap4r/lib/ap4r/queue_manager_ext_debug.rb 2007-06-06 05:21:45 UTC (rev 227) @@ -4,7 +4,7 @@ require 'drb/drb' -module ReliableMsg +module ReliableMsg #:nodoc: class QueueManager attr_reader :store, :transactions, :mutex, :config, :dispatchers, :carriers @@ -38,12 +38,16 @@ end alias e2i eval_to_inspect + # Checks queues are all "empty". + # + # "Empty" means no messages in transaction and + # all queues but $dlq are empty. def no_active_message? @transactions.size.zero? && @store.queues.all?{|(q, ms)| q == "$dlq" || ms.size.zero? } end end - module MessageStore + module MessageStore #:nodoc: class Base include DRbUndumped attr_reader :mutex, :queues, :topics, :cache @@ -53,9 +57,10 @@ def activate activate_original @mutex.extend DRbUndumped -# @queues.extend DRbUndumped -# @topics.extend DRbUndumped -# @cache.extend DRbUndumped + # TODO: queues/topics/cache should be DRbUndumped? 2007/06/06 by shino + # @queues.extend DRbUndumped + # @topics.extend DRbUndumped + # @cache.extend DRbUndumped end end Modified: trunk/ap4r/lib/ap4r/retention_history.rb =================================================================== --- trunk/ap4r/lib/ap4r/retention_history.rb 2007-06-06 02:55:04 UTC (rev 226) +++ trunk/ap4r/lib/ap4r/retention_history.rb 2007-06-06 05:21:45 UTC (rev 227) @@ -4,7 +4,8 @@ require 'active_support' -module ReliableMsg +module ReliableMsg #:nodoc: + # This class is too much experimental. # The aim: for performance monitoring, records unprocessed message count # in every queues at some interval. Modified: trunk/ap4r/lib/ap4r/script/workspace_generator.rb =================================================================== --- trunk/ap4r/lib/ap4r/script/workspace_generator.rb 2007-06-06 02:55:04 UTC (rev 226) +++ trunk/ap4r/lib/ap4r/script/workspace_generator.rb 2007-06-06 05:21:45 UTC (rev 227) @@ -8,7 +8,7 @@ module Ap4r module Script class WorkspaceGenerator < Base - AP4R_Directories = %w(config log script tmp) + AP4R_Directories = %w(config log public script tmp) def run argv, options OptionParser.new {|opt| Modified: trunk/ap4r/lib/ap4r/start_with_log4r.rb =================================================================== --- trunk/ap4r/lib/ap4r/start_with_log4r.rb 2007-06-06 02:55:04 UTC (rev 226) +++ trunk/ap4r/lib/ap4r/start_with_log4r.rb 2007-06-06 05:21:45 UTC (rev 227) @@ -2,12 +2,15 @@ # Copyright:: Copyright (c) 2007 Future Architect Inc. # Licence:: MIT Licence +# Sample script to use Log4R + require 'rubygems' require 'log4r' require 'log4r/yamlconfigurator' # we use various outputters, so require them, otherwise config chokes require 'log4r/outputter/datefileoutputter' require 'log4r/outputter/emailoutputter' + include Log4r cfg = YamlConfigurator Modified: trunk/ap4r/lib/ap4r/store_and_forward.rb =================================================================== --- trunk/ap4r/lib/ap4r/store_and_forward.rb 2007-06-06 02:55:04 UTC (rev 226) +++ trunk/ap4r/lib/ap4r/store_and_forward.rb 2007-06-06 05:21:45 UTC (rev 227) @@ -88,7 +88,7 @@ # For test if __FILE__ == $0 - class TestSaf + class TestSaf #:nodoc: include ::Ap4r::StoreAndForward From kato-k at rubyforge.org Wed Jun 6 01:51:56 2007 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Wed, 6 Jun 2007 01:51:56 -0400 (EDT) Subject: [ap4r-devel] [228] trunk/ap4r/CHANGELOG: Added comments. Message-ID: <20070606055156.C1F0E5240BF3@rubyforge.org> Revision: 228 Author: kato-k Date: 2007-06-06 01:51:56 -0400 (Wed, 06 Jun 2007) Log Message: ----------- Added comments. Modified Paths: -------------- trunk/ap4r/CHANGELOG Modified: trunk/ap4r/CHANGELOG =================================================================== --- trunk/ap4r/CHANGELOG 2007-06-06 05:21:45 UTC (rev 227) +++ trunk/ap4r/CHANGELOG 2007-06-06 05:51:56 UTC (rev 228) @@ -5,6 +5,10 @@ * Changed: Argument order of async_dispatch has changed, backward INCOMPATIBLE. * Added: Dynamic configuration with ERb. * Added: Script to run AP4R on Mongrel. +* Changed: How to plugin and main API names have changed. +* Added: Support of several Content-type on asynchronous call. +* Added: Block style for async_to. +* Added: Url rewrite filter. === 0.3.1 (April 24th, 2007) From kato-k at rubyforge.org Wed Jun 6 02:30:09 2007 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Wed, 6 Jun 2007 02:30:09 -0400 (EDT) Subject: [ap4r-devel] [229] trunk/samples/HelloWorld/vendor/plugins/ap4r/lib: Added RDoc. Message-ID: <20070606063009.8E5365240BF3@rubyforge.org> Revision: 229 Author: kato-k Date: 2007-06-06 02:30:09 -0400 (Wed, 06 Jun 2007) Log Message: ----------- Added RDoc. Modified Paths: -------------- trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/ap4r_client.rb trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/message_builder.rb Modified: trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/ap4r_client.rb =================================================================== --- trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/ap4r_client.rb 2007-06-06 05:51:56 UTC (rev 228) +++ trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/ap4r_client.rb 2007-06-06 06:30:09 UTC (rev 229) @@ -5,7 +5,7 @@ require 'forwardable' require 'async_helper' -module Ap4r +module Ap4r #:nodoc: # This +Client+ is the Rails plugin for asynchronous processing. # Asynchronous logics are called via various protocols, such as XML-RPC, Modified: trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/message_builder.rb =================================================================== --- trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/message_builder.rb 2007-06-06 05:51:56 UTC (rev 228) +++ trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/message_builder.rb 2007-06-06 06:30:09 UTC (rev 229) @@ -4,7 +4,7 @@ require 'active_record' -module Ap4r +module Ap4r #:nodoc: # This +MessageBuilder+ is the class for formatting message body. # Current support formats are text, xml, json and yaml, @@ -27,6 +27,11 @@ attr_accessor :queue_name, :message_body, :message_headers attr_reader :format, :to_xml_options + # Sets message body in async_to block. + # The first argument is key and the second one is value. + # + # options are for to_xml conversion on Array and Hash, ActiveRecord objects. + # def body(k, v, options = { }) k ||= v.class if v.kind_of? ActiveRecord::Base @@ -37,14 +42,36 @@ end end + # Sets message header in async_to block. + # The first argument is key and the second one is value. + # + # Now supports following keys: + # :expire + # :priority + # :delivery + # :max_deliveries + # :dispatch_mode + # :target_method + # :target_url + # :id + # + # For details, please refer the reliable-msg. + # def header(k, v) @message_headers[k.to_sym] = v end + # Sets http header in async_to block such as 'Content_type'. + # The first argument is key and the second one is value. + # def http_header(k, v) @message_headers["http_header_#{k}".to_sym] = v end + # Sets format message serialization. + # As to the format, automatically sets content-type. + # Unless any format, content-type is defined as "application/x-www-form-urlencoded". + # def format(v) case @format = v when :text @@ -60,26 +87,36 @@ end end + # Sets text format message. No need to use +format+. + # def body_as_text(text) @message_body_with_format = text format :text end + # Sets xml format message. No need to use +format+. + # def body_as_xml(xml) @message_body_with_format = xml format :xml end + # Sets json format message. No need to use +format+. + # def body_as_json(json) @message_body_with_format = json format :json end + # Sets yaml format message. No need to use +format+. + # def body_as_yaml(yaml) @message_body_with_format = yaml format :yaml end + # Return converted message body, as to assigned format. + # def format_message_body return @message_body_with_format if @message_body_with_format @@ -102,11 +139,11 @@ end end + private def query_string(hash) build_query_string(hash, nil, nil) end - private def build_query_string(hash, query = nil, top = nil) query ||= [] top ||= "" From shino at rubyforge.org Wed Jun 6 03:01:16 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Wed, 6 Jun 2007 03:01:16 -0400 (EDT) Subject: [ap4r-devel] [230] trunk/ap4r/README: Add URL of rubyforge's Wiki homepage. Message-ID: <20070606070117.02C095240BF1@rubyforge.org> Revision: 230 Author: shino Date: 2007-06-06 03:01:16 -0400 (Wed, 06 Jun 2007) Log Message: ----------- Add URL of rubyforge's Wiki homepage. Delete various sections which moved to Wiki. Modified Paths: -------------- trunk/ap4r/README Modified: trunk/ap4r/README =================================================================== --- trunk/ap4r/README 2007-06-06 06:30:09 UTC (rev 229) +++ trunk/ap4r/README 2007-06-06 07:01:16 UTC (rev 230) @@ -4,8 +4,10 @@ Using asynchronous processing, we can cut down turn-around-time of web applications by queuing, or can utilize more machine power by load-balancing. Also AP4R nicely ties with your Ruby on Rails applications. See Hello World sample application from rubyforge. -http://rubyforge.org/projects/ap4r/ +For more information, please step in AP4R homepage! +http://ap4r.rubyforge.org/wiki/wiki.pl + == Features 1. Business logics can be implemented as simple Web applications, or ruby code, whether it's called asynchronously or synchronously. @@ -30,149 +32,6 @@ $ sudo gem install ap4r --include-dependencies - -== Working directory - -Create your working directory (ex. my_work) wherever you want. - - $ ap4r_setup my_work - $ cd my_work - -Its structure is as follows. - - my_work - +-- config - +-- log - +-- script - +-- tmp - -== Message Persistence - -AP4R uses reliable-msg for message persistence. It enables disk or RDBMS persistence. See references for details of reliable-msg. Install MySQL if you choose MySQL persistence. We recommend to install MySQL/Ruby library to connect to MySQL. For convinience, Ruby/MySQL bundled in the ActiveRecord gem can be used. -Create a table in your database. (If you use topics via reliable-msg, create another slightly different table.) - - CREATE TABLE `reliable_msg_queues` ( - `id` varchar(255) NOT NULL default '', - `queue` varchar(255) NOT NULL default '', - `headers` text NOT NULL, - `object` blob NOT NULL, - PRIMARY KEY (`id`) - ) ENGINE=InnoDB DEFAULT CHARSET=binary; - -== Configuration file - -A command ap4r_setup have created a template configuration file (my_work/config/queues.cfg). - - --- - store: - type: mysql - host: localhost - database: test - username: test - password: - drb: - host: - port: 6438 - acl: allow 127.0.0.1 - dispatchers: - - - targets: queue.* - threads: 1 - #carriers: - # - - # source_uri: druby://another.host.local:6438 - # threads: 1 - -queues.cfg has four parts. - -* persistent role (store: ) - * Set database or file information. - -* message listener (drb:) - * Set IP, and port number which are used by clients. - * acl = access control list, exmaple below. - - allow 127.0.0.1 allow 10.0.0.0/8 deny 192.168.0.1 - -* asynchronous process invokers (dispatchers:) - * Dispatchers handle messages in queues specified by targets, - * with as many threads as specified by threads. - * Each thread waits (is blocked) until the invocation returns. - -* message routing (carriers:) # EXPERIMENTAL - * Carriers get messages from an AP4R server specified by source_uri, - * with as many threads as specified by threads, - * and put messages to a local AP4R server. - -== Monitoring - -Future plan: connections with monitoring tools such as Cacti and ZABBIX. - -* Cacti - * http://www.cacti.net/ -* ZABBIX - * http://www.zabbix.org/ - -== Sample - HelloWorld - - -There is an asynchronous application sample with file persistence, where a synchronous logic outputs "Hello" to a file, and an asynchronous logic appends "World". -Once the synchronous logic has done, a client (a web browser) displays response, and there is only "Hello" in a file. -Since the asynchronous logic sleeps ten seconds and appends to the file, wait briefly and you can see whole "HelloWorld" in the file - -* Install Ruby, Rails and AP4R and configure AP4R in reference above sections - * No need for MySQL. - -* Make sample application available - * If you have an SVN client, - - $ svn co svn://rubyforge.org/var/ap4r/tags/ap4r-0.2.0/sample [some directory] - - * Unless - 1. download the sample from RubyForge - http://rubyforge.org/projects/ap4r/ - filename: HelloWorld.tar.gz - - 1. and extract to an appropricate directory(ex. HelloWorld ). - There are app/, components/,... directories under HelloWorld. - -* Start WEBRick. - * In a command line - - $ cd HelloWorld - $ ruby script\server - - * If you see Welcome screen at http://localhost:3000, it's ok. - -* Start AP4R. - * In another command line, - * start AP4R with specifying the configuraion file. - - $ cd my_work - $ ruby script/start -c config/queues_disk.cfg - -* Execute a synchronous logic. - * http://localhost:3000/sync_hello/execute - * A file HelloWorld.txt is creted under HelloWorld/ which contains a word "Hello". - * execute_via_soap, execute_via_http and execute_with_saf actions are also available. - -* Confirm the execution of an asynchronous logic. - * Wait ten seconds, - * and look into the file HelloWorld.txt again, there must be "HelloWorld". - -* Think of application to your real application - * This mechanism can work in general applications. - * An order acceptance logic instead of printing "Hello". - * Asynchronous logic of auto shipping order or accounting instead of appending "World". - -== Future Plans - -* only-once QoS -* DLQ recovery -* flow volume control, load balancing -* 7x24 support (e.g. rolling database tables) -* monitoring (e.g. thread status, web frontend) -* Coordination with Ruby on Rails, such as development/testing lifesycle support. - == References * Ruby Homepage From kato-k at rubyforge.org Wed Jun 6 03:26:03 2007 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Wed, 6 Jun 2007 03:26:03 -0400 (EDT) Subject: [ap4r-devel] [231] trunk/ap4r/Rakefile: Added gem dependency. Message-ID: <20070606072603.BEE0E5240BF2@rubyforge.org> Revision: 231 Author: kato-k Date: 2007-06-06 03:26:03 -0400 (Wed, 06 Jun 2007) Log Message: ----------- Added gem dependency. Modified Paths: -------------- trunk/ap4r/Rakefile Modified: trunk/ap4r/Rakefile =================================================================== --- trunk/ap4r/Rakefile 2007-06-06 07:01:16 UTC (rev 230) +++ trunk/ap4r/Rakefile 2007-06-06 07:26:03 UTC (rev 231) @@ -59,6 +59,9 @@ EOF s.add_dependency(%q, ["= 1.1.0"]) + s.add_dependency(%q) + s.add_dependency(%q) + s.add_dependency(%q) s.has_rdoc = true s.extra_rdoc_files = ["README", "CHANGELOG", 'rails_plugin'] From kato-k at rubyforge.org Wed Jun 6 04:17:32 2007 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Wed, 6 Jun 2007 04:17:32 -0400 (EDT) Subject: [ap4r-devel] [232] trunk/ap4r/Rakefile: Changed copy files from sample to ap4r. Message-ID: <20070606081732.6E38C5240BF2@rubyforge.org> Revision: 232 Author: kato-k Date: 2007-06-06 04:17:28 -0400 (Wed, 06 Jun 2007) Log Message: ----------- Changed copy files from sample to ap4r. Modified Paths: -------------- trunk/ap4r/Rakefile Modified: trunk/ap4r/Rakefile =================================================================== --- trunk/ap4r/Rakefile 2007-06-06 07:26:03 UTC (rev 231) +++ trunk/ap4r/Rakefile 2007-06-06 08:17:28 UTC (rev 232) @@ -132,7 +132,9 @@ FileUtils.cp(HELLO_WORLD_DIR + '/db/migrate/001_create_table_for_saf.rb', './lib/ap4r/xxx_create_table_for_saf.rb') FileUtils.cp(HELLO_WORLD_DIR + '/vendor/plugins/ap4r/init.rb', './rails_plugin/ap4r/init.rb') - FileUtils.cp(HELLO_WORLD_DIR + '/vendor/plugins/ap4r/lib/async_controller.rb', './rails_plugin/ap4r/lib/async_controller.rb') + FileUtils.cp(HELLO_WORLD_DIR + '/vendor/plugins/ap4r/lib/async_helper.rb', './rails_plugin/ap4r/lib/async_helper.rb') + FileUtils.cp(HELLO_WORLD_DIR + '/vendor/plugins/ap4r/lib/ap4r_client.rb', './rails_plugin/ap4r/lib/ap4r_client.rb') + FileUtils.cp(HELLO_WORLD_DIR + '/vendor/plugins/ap4r/lib/message_builder.rb', './rails_plugin/ap4r/lib/message_builder.rb') end desc "Make sample tgz" From kato-k at rubyforge.org Wed Jun 6 04:28:38 2007 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Wed, 6 Jun 2007 04:28:38 -0400 (EDT) Subject: [ap4r-devel] [233] trunk/ap4r/rails_plugin/ap4r/init.rb: Removed unnecessary file. Message-ID: <20070606082838.AB0645240BF3@rubyforge.org> Revision: 233 Author: kato-k Date: 2007-06-06 04:28:38 -0400 (Wed, 06 Jun 2007) Log Message: ----------- Removed unnecessary file. Removed Paths: ------------- trunk/ap4r/rails_plugin/ap4r/init.rb Deleted: trunk/ap4r/rails_plugin/ap4r/init.rb =================================================================== --- trunk/ap4r/rails_plugin/ap4r/init.rb 2007-06-06 08:17:28 UTC (rev 232) +++ trunk/ap4r/rails_plugin/ap4r/init.rb 2007-06-06 08:28:38 UTC (rev 233) @@ -1,10 +0,0 @@ -# Author:: Shunichi Shinohara -# Copyright:: Copyright (c) 2007 Future Architect Inc. -# Licence:: MIT Licence - -require 'async_controller' -require 'ap4r/stored_message' - -class ActionController::Base - include Ap4r::AsyncController::Base -end From kato-k at rubyforge.org Wed Jun 6 04:29:22 2007 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Wed, 6 Jun 2007 04:29:22 -0400 (EDT) Subject: [ap4r-devel] [234] trunk/ap4r/Rakefile: Modified directory path. Message-ID: <20070606082922.A92995240BF3@rubyforge.org> Revision: 234 Author: kato-k Date: 2007-06-06 04:29:22 -0400 (Wed, 06 Jun 2007) Log Message: ----------- Modified directory path. Modified Paths: -------------- trunk/ap4r/Rakefile Modified: trunk/ap4r/Rakefile =================================================================== --- trunk/ap4r/Rakefile 2007-06-06 08:28:38 UTC (rev 233) +++ trunk/ap4r/Rakefile 2007-06-06 08:29:22 UTC (rev 234) @@ -168,9 +168,9 @@ end task :execute_migration do - Dir.chdir('temp/') + Dir.chdir('temp/HelloWorld') `rake db:migrate` - Dir.chdir('../') + Dir.chdir('../../') end task :make_tgz do From kato-k at rubyforge.org Wed Jun 6 05:29:44 2007 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Wed, 6 Jun 2007 05:29:44 -0400 (EDT) Subject: [ap4r-devel] [235] tags/ap4r-0.3.2/: tag 0.3.2 Message-ID: <20070606092944.6670F5240A33@rubyforge.org> Revision: 235 Author: kato-k Date: 2007-06-06 05:29:42 -0400 (Wed, 06 Jun 2007) Log Message: ----------- tag 0.3.2 Added Paths: ----------- tags/ap4r-0.3.2/ Copied: tags/ap4r-0.3.2 (from rev 234, trunk) From kato-k at rubyforge.org Wed Jun 6 21:58:50 2007 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Wed, 6 Jun 2007 21:58:50 -0400 (EDT) Subject: [ap4r-devel] [236] trunk/ap4r/lib: Removed gem method which interferes in working on Windows except with the latest Ruby and RubyGems. Message-ID: <20070607015850.24A1A5240BBE@rubyforge.org> Revision: 236 Author: kato-k Date: 2007-06-06 21:58:49 -0400 (Wed, 06 Jun 2007) Log Message: ----------- Removed gem method which interferes in working on Windows except with the latest Ruby and RubyGems. Modified Paths: -------------- trunk/ap4r/lib/ap4r/script/setup.rb trunk/ap4r/lib/ap4r/stored_message.rb trunk/ap4r/lib/ap4r.rb Modified: trunk/ap4r/lib/ap4r/script/setup.rb =================================================================== --- trunk/ap4r/lib/ap4r/script/setup.rb 2007-06-06 09:29:42 UTC (rev 235) +++ trunk/ap4r/lib/ap4r/script/setup.rb 2007-06-07 01:58:49 UTC (rev 236) @@ -9,7 +9,6 @@ require 'active_support' rescue LoadError require 'rubygems' - gem 'active_support' require 'active_support' end Modified: trunk/ap4r/lib/ap4r/stored_message.rb =================================================================== --- trunk/ap4r/lib/ap4r/stored_message.rb 2007-06-06 09:29:42 UTC (rev 235) +++ trunk/ap4r/lib/ap4r/stored_message.rb 2007-06-07 01:58:49 UTC (rev 236) @@ -7,9 +7,7 @@ require 'uuid' rescue LoadError require 'rubygems' - gem 'activerecord' require 'activerecord' - gem 'uuid' require 'uuid' end Modified: trunk/ap4r/lib/ap4r.rb =================================================================== --- trunk/ap4r/lib/ap4r.rb 2007-06-06 09:29:42 UTC (rev 235) +++ trunk/ap4r/lib/ap4r.rb 2007-06-07 01:58:49 UTC (rev 236) @@ -3,7 +3,6 @@ # Licence:: MIT Licence require 'rubygems' -gem 'reliable-msg' require 'reliable-msg' hack = true From kato-k at rubyforge.org Wed Jun 6 22:00:46 2007 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Wed, 6 Jun 2007 22:00:46 -0400 (EDT) Subject: [ap4r-devel] [237] trunk/ap4r/lib/ap4r/version.rb: Modified version. Message-ID: <20070607020046.7AF015240BBE@rubyforge.org> Revision: 237 Author: kato-k Date: 2007-06-06 22:00:46 -0400 (Wed, 06 Jun 2007) Log Message: ----------- Modified version. Modified Paths: -------------- trunk/ap4r/lib/ap4r/version.rb Modified: trunk/ap4r/lib/ap4r/version.rb =================================================================== --- trunk/ap4r/lib/ap4r/version.rb 2007-06-07 01:58:49 UTC (rev 236) +++ trunk/ap4r/lib/ap4r/version.rb 2007-06-07 02:00:46 UTC (rev 237) @@ -8,7 +8,7 @@ module VERSION #:nodoc: MAJOR = 0 MINOR = 3 - TINY = 2 + TINY = 3 STRING = [MAJOR, MINOR, TINY].join('.') end From kato-k at rubyforge.org Thu Jun 7 06:59:33 2007 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Thu, 7 Jun 2007 06:59:33 -0400 (EDT) Subject: [ap4r-devel] [238] trunk/samples/HelloWorld/app: Just ported demo application from zookeeper, maybe it does't work. Message-ID: <20070607105933.8781F5240A91@rubyforge.org> Revision: 238 Author: kato-k Date: 2007-06-07 06:59:33 -0400 (Thu, 07 Jun 2007) Log Message: ----------- Just ported demo application from zookeeper, maybe it does't work. Added Paths: ----------- trunk/samples/HelloWorld/app/controllers/async_shop_controller.rb trunk/samples/HelloWorld/app/controllers/msg_retention_controller.rb trunk/samples/HelloWorld/app/controllers/shop_controller.rb trunk/samples/HelloWorld/app/helpers/async_shop_helper.rb trunk/samples/HelloWorld/app/helpers/msg_retention_helper.rb trunk/samples/HelloWorld/app/helpers/shop_helper.rb trunk/samples/HelloWorld/app/models/ap4r.rb trunk/samples/HelloWorld/app/models/ap4r_group.rb trunk/samples/HelloWorld/app/views/async_shop/ trunk/samples/HelloWorld/app/views/msg_retention/ trunk/samples/HelloWorld/app/views/msg_retention/load2replace_by_js.rhtml trunk/samples/HelloWorld/app/views/msg_retention/retention.rhtml trunk/samples/HelloWorld/app/views/msg_retention/status_img.rhtml trunk/samples/HelloWorld/app/views/shop/ trunk/samples/HelloWorld/app/views/shop/account.rhtml trunk/samples/HelloWorld/app/views/shop/order.rhtml Added: trunk/samples/HelloWorld/app/controllers/async_shop_controller.rb =================================================================== --- trunk/samples/HelloWorld/app/controllers/async_shop_controller.rb (rev 0) +++ trunk/samples/HelloWorld/app/controllers/async_shop_controller.rb 2007-06-07 10:59:33 UTC (rev 238) @@ -0,0 +1,22 @@ +class AsyncShopController < ApplicationController + + def order + ap4r.transaction do + # ???? + # ... + + # ???? (??????????????) + ap4r.async_to({:action => 'account2'}, + {:sleep_time => params[:weight]}) + end + + render :text => 'Order completed successfully.' + end + + def account + sleep rand(params[:sleep_time]) + + render :text => 'true' + end + +end Added: trunk/samples/HelloWorld/app/controllers/msg_retention_controller.rb =================================================================== --- trunk/samples/HelloWorld/app/controllers/msg_retention_controller.rb (rev 0) +++ trunk/samples/HelloWorld/app/controllers/msg_retention_controller.rb 2007-06-07 10:59:33 UTC (rev 238) @@ -0,0 +1,123 @@ +class MsgRetentionController < ApplicationController + + DEFAULT_INTERVAL = 3 #sec + DEFAULT_RANGE = 5 + RETENTION_STATUS = Hash.new + AP4R_LIST = Array.new + LABEL_LIST = Array.new + + def retention_status_by_gruff + + if params[:interval] != nil then + interval = params[:interval].to_i + else + interval = DEFAULT_INTERVAL + end + + if params[:range] != nil then + maxRange = params[:range].to_i + else + maxRange = DEFAULT_RANGE + end + + if params[:type] != nil then + g = Gruff.const_get(params[:type]).new 500 + else + g = Gruff::Line.new 500 + end + + if params[:theme] != nil then + g.__send__(params[:theme]) + else + g.theme_37signals + end + + g.title = "Message retension #{Time.now.to_formatted_s}" + g.minimum_value = 0 + g.maximum_value = 50 + + currentTime = Time.now.to_i + maxRange.times{|r| + LABEL_LIST.push(Time.at(currentTime-(maxRange-r-1)*interval).strftime("%X")) + } + g.labels = LABEL_LIST.each{|l| "#{l}"} + + qms = OrcaGroup::Default.map{|n, qm| [n, qm]} + qms.each{|on|on;AP4R_LIST.push(on[0])} + + #??????????????? + AP4R_LIST.each{|on| + qms.each{|n, qm| + if(n == on && qm != nil) then + qm.retention.data.each{|qn, stat| + stat.each{|time, num| + maxRange.times{|r| + fromTime =currentTime-(maxRange-r)*interval + toTime = currentTime-(maxRange-r-1)*interval + if(time.to_i>fromTime && time.to_i<=toTime) then + calcAverage(on, qn, r, num) + end + } + } + } + end + } + } + + #??????????????? + RETENTION_STATUS.each{|on, qs| + _rs = Hash.new + qs.each{|q,rs| + rs.each{|r,ave| + if(_rs.key?(r) && ((_ave=_rs.fetch(r))!=nil)) then + _ave=_ave+ave[0] + else + _ave=ave[0] + end + _rs.store(r,_ave) + } + } + qs.store(:'summary',_rs) + } + + RETENTION_STATUS.each {|on, qs| + sortedNum = Array.new + maxRange.times{|r| + sortedNum.push(qs.fetch(:'summary').fetch(r)) + } + g.data(on, sortedNum) + } + + send_data(g.to_blob,# :filename => "retention_#{Time.now.to_i}.png", + :type => 'image/png', :disposition => 'inline') + end + + + def calcAverage(oname, qname, range, num) + + if(RETENTION_STATUS.key?(oname) && (qs=RETENTION_STATUS.fetch(oname)) != nil) then + if(qs.key?(qname) && (rs=qs.fetch(qname)) != nil) then + if(rs.key?(range) && (ave=rs.fetch(range)) != nil) then + ave[0]=(ave[0]*ave[1]+num)/(ave[1]+1) + ave[1]=ave[1]+1 + else + ave = [0,0] + end + rs.store(range,ave) + else + ave = [0,0] + rs = Hash.new + rs.store(range,ave) + end + qs.store(qname,rs) + else + ave = [0,0] + rs = Hash.new + rs.store(range,ave) + qs = Hash.new + qs.store(qname, rs) + end + RETENTION_STATUS.store(oname,qs) + end + +end Added: trunk/samples/HelloWorld/app/controllers/shop_controller.rb =================================================================== --- trunk/samples/HelloWorld/app/controllers/shop_controller.rb (rev 0) +++ trunk/samples/HelloWorld/app/controllers/shop_controller.rb 2007-06-07 10:59:33 UTC (rev 238) @@ -0,0 +1,17 @@ +class ShopController < ApplicationController + + def order + # ???? + # ... + + # ???? (??????????????) + account params[:weight] + end + + def account sleep_time + sleep rand(sleep_time) + + render :text => 'Order completed successfully.' + end + +end Added: trunk/samples/HelloWorld/app/helpers/async_shop_helper.rb =================================================================== --- trunk/samples/HelloWorld/app/helpers/async_shop_helper.rb (rev 0) +++ trunk/samples/HelloWorld/app/helpers/async_shop_helper.rb 2007-06-07 10:59:33 UTC (rev 238) @@ -0,0 +1,2 @@ +module AsyncShopHelper +end Added: trunk/samples/HelloWorld/app/helpers/msg_retention_helper.rb =================================================================== --- trunk/samples/HelloWorld/app/helpers/msg_retention_helper.rb (rev 0) +++ trunk/samples/HelloWorld/app/helpers/msg_retention_helper.rb 2007-06-07 10:59:33 UTC (rev 238) @@ -0,0 +1,2 @@ +module MsgRetentionHelper +end Added: trunk/samples/HelloWorld/app/helpers/shop_helper.rb =================================================================== --- trunk/samples/HelloWorld/app/helpers/shop_helper.rb (rev 0) +++ trunk/samples/HelloWorld/app/helpers/shop_helper.rb 2007-06-07 10:59:33 UTC (rev 238) @@ -0,0 +1,2 @@ +module ShopHelper +end Added: trunk/samples/HelloWorld/app/models/ap4r.rb =================================================================== --- trunk/samples/HelloWorld/app/models/ap4r.rb (rev 0) +++ trunk/samples/HelloWorld/app/models/ap4r.rb 2007-06-07 10:59:33 UTC (rev 238) @@ -0,0 +1,12 @@ +require 'drb/drb' + +class Ap4r + attr_reader :name, :uri, :remote + + def initialize name, uri + @name = name + @uri = uri + @remote = DRb::DRbObject.new_with_uri(uri) + end + +end Added: trunk/samples/HelloWorld/app/models/ap4r_group.rb =================================================================== --- trunk/samples/HelloWorld/app/models/ap4r_group.rb (rev 0) +++ trunk/samples/HelloWorld/app/models/ap4r_group.rb 2007-06-07 10:59:33 UTC (rev 238) @@ -0,0 +1,38 @@ +class Ap4rGroup + include Enumerable + + attr_reader :name, :servers + + def initialize name + @name = name + @servers = {} + end + + Default = Ap4rGroup.new('default') + GROUPS = {:default => Default} + + def each + for name in @servers.keys + yield name, @servers[name].remote + end + end + + def add ap4r_name, uri, key = :default + @servers[ap4r_name] = Ap4r.new(ap4r_name, uri) + end + + def [](name) + @servers[name].remote if @servers[name] + end + + def self.get key = :default + GROUPS[key] + end + + # configuration stub below here + default = self.get() + 8.upto(8) do |index| + default.add("ap4r#{index}", "druby://localhost:643#{index}") + end + +end Added: trunk/samples/HelloWorld/app/views/msg_retention/load2replace_by_js.rhtml =================================================================== --- trunk/samples/HelloWorld/app/views/msg_retention/load2replace_by_js.rhtml (rev 0) +++ trunk/samples/HelloWorld/app/views/msg_retention/load2replace_by_js.rhtml 2007-06-07 10:59:33 UTC (rev 238) @@ -0,0 +1,35 @@ + + + load and replace by JavaScript test + + + + + + + + Added: trunk/samples/HelloWorld/app/views/msg_retention/retention.rhtml =================================================================== --- trunk/samples/HelloWorld/app/views/msg_retention/retention.rhtml (rev 0) +++ trunk/samples/HelloWorld/app/views/msg_retention/retention.rhtml 2007-06-07 10:59:33 UTC (rev 238) @@ -0,0 +1,21 @@ + + +retention status view +<%= javascript_include_tag "prototype" %> + + + +

Message Retension Status

+ +
+ +
+ + <%= periodically_call_remote( :update => 'image', + :url => {:action => :status_img}, + :frequency => 3 )%> + + + + Added: trunk/samples/HelloWorld/app/views/msg_retention/status_img.rhtml =================================================================== --- trunk/samples/HelloWorld/app/views/msg_retention/status_img.rhtml (rev 0) +++ trunk/samples/HelloWorld/app/views/msg_retention/status_img.rhtml 2007-06-07 10:59:33 UTC (rev 238) @@ -0,0 +1,2 @@ + Added: trunk/samples/HelloWorld/app/views/shop/account.rhtml =================================================================== --- trunk/samples/HelloWorld/app/views/shop/account.rhtml (rev 0) +++ trunk/samples/HelloWorld/app/views/shop/account.rhtml 2007-06-07 10:59:33 UTC (rev 238) @@ -0,0 +1,2 @@ +

Shop#account

+

Find me in app/views/shop/account.rhtml

Added: trunk/samples/HelloWorld/app/views/shop/order.rhtml =================================================================== --- trunk/samples/HelloWorld/app/views/shop/order.rhtml (rev 0) +++ trunk/samples/HelloWorld/app/views/shop/order.rhtml 2007-06-07 10:59:33 UTC (rev 238) @@ -0,0 +1,2 @@ +

Shop#order

+

Find me in app/views/shop/order.rhtml

From kato-k at rubyforge.org Thu Jun 7 20:19:35 2007 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Thu, 7 Jun 2007 20:19:35 -0400 (EDT) Subject: [ap4r-devel] [239] trunk: Modified message retention monitoring in an impromptu manner. Message-ID: <20070608001935.5612C5240C1F@rubyforge.org> Revision: 239 Author: kato-k Date: 2007-06-07 20:19:34 -0400 (Thu, 07 Jun 2007) Log Message: ----------- Modified message retention monitoring in an impromptu manner. Modified Paths: -------------- trunk/ap4r/lib/ap4r/retention_history.rb trunk/samples/HelloWorld/app/controllers/async_shop_controller.rb trunk/samples/HelloWorld/app/controllers/msg_retention_controller.rb trunk/samples/HelloWorld/app/models/ap4r_group.rb trunk/samples/HelloWorld/app/views/msg_retention/load2replace_by_js.rhtml trunk/samples/HelloWorld/config/environment.rb Added Paths: ----------- trunk/samples/HelloWorld/app/models/ap4r_class.rb Removed Paths: ------------- trunk/samples/HelloWorld/app/models/ap4r.rb Modified: trunk/ap4r/lib/ap4r/retention_history.rb =================================================================== --- trunk/ap4r/lib/ap4r/retention_history.rb 2007-06-07 10:59:33 UTC (rev 238) +++ trunk/ap4r/lib/ap4r/retention_history.rb 2007-06-08 00:19:34 UTC (rev 239) @@ -12,8 +12,8 @@ class RetentionHistory include DRbUndumped - LOOP_INTERVAL = 3.seconds - SHELF_LIFE = 1.hour + LOOP_INTERVAL = 1.seconds + SHELF_LIFE = 10.minutes # SHELF_LIFE = 10.seconds attr_reader :data Modified: trunk/samples/HelloWorld/app/controllers/async_shop_controller.rb =================================================================== --- trunk/samples/HelloWorld/app/controllers/async_shop_controller.rb 2007-06-07 10:59:33 UTC (rev 238) +++ trunk/samples/HelloWorld/app/controllers/async_shop_controller.rb 2007-06-08 00:19:34 UTC (rev 239) @@ -1,20 +1,20 @@ class AsyncShopController < ApplicationController def order - ap4r.transaction do +# ap4r.transaction do # ???? # ... # ???? (??????????????) - ap4r.async_to({:action => 'account2'}, - {:sleep_time => params[:weight]}) - end + ap4r.async_to({:action => 'account'}, + {:sleep_time => params[id]}) +# end render :text => 'Order completed successfully.' end def account - sleep rand(params[:sleep_time]) + sleep rand(params[:sleep_time].to_i) render :text => 'true' end Modified: trunk/samples/HelloWorld/app/controllers/msg_retention_controller.rb =================================================================== --- trunk/samples/HelloWorld/app/controllers/msg_retention_controller.rb 2007-06-07 10:59:33 UTC (rev 238) +++ trunk/samples/HelloWorld/app/controllers/msg_retention_controller.rb 2007-06-08 00:19:34 UTC (rev 239) @@ -1,99 +1,77 @@ class MsgRetentionController < ApplicationController - DEFAULT_INTERVAL = 3 #sec - DEFAULT_RANGE = 5 - RETENTION_STATUS = Hash.new - AP4R_LIST = Array.new - LABEL_LIST = Array.new + RETENTION_STATUS = {} def retention_status_by_gruff - if params[:interval] != nil then - interval = params[:interval].to_i - else - interval = DEFAULT_INTERVAL - end + interval = 5 + max_range = 6 - if params[:range] != nil then - maxRange = params[:range].to_i - else - maxRange = DEFAULT_RANGE - end - - if params[:type] != nil then - g = Gruff.const_get(params[:type]).new 500 - else - g = Gruff::Line.new 500 - end - - if params[:theme] != nil then - g.__send__(params[:theme]) - else - g.theme_37signals - end - - g.title = "Message retension #{Time.now.to_formatted_s}" + g = Gruff::Area.new 600 + g.theme_keynote + g.title = "Message retension" g.minimum_value = 0 g.maximum_value = 50 - currentTime = Time.now.to_i - maxRange.times{|r| - LABEL_LIST.push(Time.at(currentTime-(maxRange-r-1)*interval).strftime("%X")) - } - g.labels = LABEL_LIST.each{|l| "#{l}"} + g.labels = {} + current_time = Time.now.to_i + max_range.times do |r| + g.labels[max_range-r-1] = Time.at(current_time-(max_range-r-1)*interval).strftime("%X") + end - qms = OrcaGroup::Default.map{|n, qm| [n, qm]} - qms.each{|on|on;AP4R_LIST.push(on[0])} + ap4rs = [] + qms = Ap4rGroup::Default.map{|n, qm| [n, qm]} + qms.each{|on| ap4rs << on[0]} #??????????????? - AP4R_LIST.each{|on| - qms.each{|n, qm| + ap4rs.each do |on| + qms.each do |n, qm| if(n == on && qm != nil) then - qm.retention.data.each{|qn, stat| - stat.each{|time, num| - maxRange.times{|r| - fromTime =currentTime-(maxRange-r)*interval - toTime = currentTime-(maxRange-r-1)*interval - if(time.to_i>fromTime && time.to_i<=toTime) then - calcAverage(on, qn, r, num) + qm.retention.data.each do |qn, stat| + stat.each do |time, num| + max_range.times do |r| + from_time =current_time-(max_range-r)*interval + to_time = current_time-(max_range-r-1)*interval + if(time.to_i>from_time && time.to_i<=to_time) then + calc_average(on, qn, r, num) end - } - } - } + end + end + end end - } - } + end + end #??????????????? - RETENTION_STATUS.each{|on, qs| + RETENTION_STATUS.each do |on, qs| _rs = Hash.new - qs.each{|q,rs| - rs.each{|r,ave| + qs.each do |q,rs| + rs.each do |r,ave| if(_rs.key?(r) && ((_ave=_rs.fetch(r))!=nil)) then _ave=_ave+ave[0] else _ave=ave[0] end _rs.store(r,_ave) - } - } + end + end qs.store(:'summary',_rs) - } + end - RETENTION_STATUS.each {|on, qs| - sortedNum = Array.new - maxRange.times{|r| - sortedNum.push(qs.fetch(:'summary').fetch(r)) - } - g.data(on, sortedNum) - } + RETENTION_STATUS.each do |on, qs| + sorted_num = Array.new + max_range.times do |r| + sorted_num << qs[:summary][r] + end + g.data(on, sorted_num) + end send_data(g.to_blob,# :filename => "retention_#{Time.now.to_i}.png", :type => 'image/png', :disposition => 'inline') end - def calcAverage(oname, qname, range, num) + def calc_average(oname, qname, range, num) if(RETENTION_STATUS.key?(oname) && (qs=RETENTION_STATUS.fetch(oname)) != nil) then if(qs.key?(qname) && (rs=qs.fetch(qname)) != nil) then Deleted: trunk/samples/HelloWorld/app/models/ap4r.rb =================================================================== --- trunk/samples/HelloWorld/app/models/ap4r.rb 2007-06-07 10:59:33 UTC (rev 238) +++ trunk/samples/HelloWorld/app/models/ap4r.rb 2007-06-08 00:19:34 UTC (rev 239) @@ -1,12 +0,0 @@ -require 'drb/drb' - -class Ap4r - attr_reader :name, :uri, :remote - - def initialize name, uri - @name = name - @uri = uri - @remote = DRb::DRbObject.new_with_uri(uri) - end - -end Added: trunk/samples/HelloWorld/app/models/ap4r_class.rb =================================================================== --- trunk/samples/HelloWorld/app/models/ap4r_class.rb (rev 0) +++ trunk/samples/HelloWorld/app/models/ap4r_class.rb 2007-06-08 00:19:34 UTC (rev 239) @@ -0,0 +1,12 @@ +require 'drb/drb' + +class Ap4rClass + attr_reader :name, :uri, :remote + + def initialize name, uri + @name = name + @uri = uri + @remote = DRb::DRbObject.new_with_uri(uri) + end + +end Modified: trunk/samples/HelloWorld/app/models/ap4r_group.rb =================================================================== --- trunk/samples/HelloWorld/app/models/ap4r_group.rb 2007-06-07 10:59:33 UTC (rev 238) +++ trunk/samples/HelloWorld/app/models/ap4r_group.rb 2007-06-08 00:19:34 UTC (rev 239) @@ -18,7 +18,7 @@ end def add ap4r_name, uri, key = :default - @servers[ap4r_name] = Ap4r.new(ap4r_name, uri) + @servers[ap4r_name] = Ap4rClass.new(ap4r_name, uri) end def [](name) @@ -32,7 +32,7 @@ # configuration stub below here default = self.get() 8.upto(8) do |index| - default.add("ap4r#{index}", "druby://localhost:643#{index}") + default.add("ap4r:643#{index}", "druby://localhost:643#{index}") end end Modified: trunk/samples/HelloWorld/app/views/msg_retention/load2replace_by_js.rhtml =================================================================== --- trunk/samples/HelloWorld/app/views/msg_retention/load2replace_by_js.rhtml 2007-06-07 10:59:33 UTC (rev 238) +++ trunk/samples/HelloWorld/app/views/msg_retention/load2replace_by_js.rhtml 2007-06-08 00:19:34 UTC (rev 239) @@ -9,14 +9,14 @@ var url_base = '<%= url_for(:action => :retention_status_by_gruff) %>'; var time = (new Date()).getTime(); var url = url_base + "?time=" + time; - var type = top.menu.document.gconf.gtype.value; - var url = url + "&type=" + type; - var theme = top.menu.document.gconf.gtheme.value; - var url = url + "&theme=" + theme; - var interval = top.menu.document.gconf.ginterval.value; - var url = url + "&interval=" + interval; - var range = top.menu.document.gconf.grange.value; - var url = url + "&range=" + range; +// var type = top.menu.document.gconf.gtype.value; +// var url = url + "&type=" + type; +// var theme = top.menu.document.gconf.gtheme.value; +// var url = url + "&theme=" + theme; +// var interval = top.menu.document.gconf.ginterval.value; +// var url = url + "&interval=" + interval; +// var range = top.menu.document.gconf.grange.value; +// var url = url + "&range=" + range; // alert(url); (new Image()).src=url; Modified: trunk/samples/HelloWorld/config/environment.rb =================================================================== --- trunk/samples/HelloWorld/config/environment.rb 2007-06-07 10:59:33 UTC (rev 238) +++ trunk/samples/HelloWorld/config/environment.rb 2007-06-08 00:19:34 UTC (rev 239) @@ -1,6 +1,6 @@ # Be sure to restart your web server when you modify this file. -# Uncomment below to force Rails into production mode when +# Uncomment below to force Rails into production mode when # you don't control web/app server and can't set it the proper way # ENV['RAILS_ENV'] ||= 'production' @@ -12,7 +12,7 @@ Rails::Initializer.run do |config| # Settings in config/environments/* take precedence over those specified here - + # Skip frameworks you're not going to use (only works if using vendor/rails) # config.frameworks -= [ :action_web_service, :action_mailer ] @@ -22,7 +22,7 @@ # Add additional load paths for your own custom dirs # config.load_paths += %W( #{RAILS_ROOT}/extras ) - # Force all environments to use the same logger level + # Force all environments to use the same logger level # (by default production uses :info, the others :debug) # config.log_level = :debug @@ -31,7 +31,7 @@ # config.action_controller.session_store = :active_record_store # Use SQL instead of Active Record's schema dumper when creating the test database. - # This is necessary if your schema can't be completely dumped by the schema dumper, + # This is necessary if your schema can't be completely dumped by the schema dumper, # like if you have constraints or database-specific column types # config.active_record.schema_format = :sql @@ -40,11 +40,11 @@ # Make Active Record use UTC-base instead of local time # config.active_record.default_timezone = :utc - + # See Rails::Configuration for more options end -# Add new inflection rules using the following format +# Add new inflection rules using the following format # (all these examples are active by default): # Inflector.inflections do |inflect| # inflect.plural /^(ox)$/i, '\1en' @@ -57,4 +57,6 @@ # Mime::Type.register "text/richtext", :rtf # Mime::Type.register "application/x-mobile", :mobile -# Include your application configuration below \ No newline at end of file +# Include your application configuration below + +require 'gruff' From kato-k at rubyforge.org Tue Jun 12 20:55:42 2007 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Tue, 12 Jun 2007 20:55:42 -0400 (EDT) Subject: [ap4r-devel] [240] trunk/samples/HelloWorld/app/controllers/msg_retention_controller.rb: Refactoring, not yet finished. Message-ID: <20070613005542.EE1345240B0E@rubyforge.org> Revision: 240 Author: kato-k Date: 2007-06-12 20:55:41 -0400 (Tue, 12 Jun 2007) Log Message: ----------- Refactoring, not yet finished. Modified Paths: -------------- trunk/samples/HelloWorld/app/controllers/msg_retention_controller.rb Modified: trunk/samples/HelloWorld/app/controllers/msg_retention_controller.rb =================================================================== --- trunk/samples/HelloWorld/app/controllers/msg_retention_controller.rb 2007-06-08 00:19:34 UTC (rev 239) +++ trunk/samples/HelloWorld/app/controllers/msg_retention_controller.rb 2007-06-13 00:55:41 UTC (rev 240) @@ -11,7 +11,7 @@ g.theme_keynote g.title = "Message retension" g.minimum_value = 0 - g.maximum_value = 50 + g.maximum_value = 100 g.labels = {} current_time = Time.now.to_i From shino at rubyforge.org Fri Jun 15 04:30:13 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Fri, 15 Jun 2007 04:30:13 -0400 (EDT) Subject: [ap4r-devel] [241] trunk/ap4r/rails_plugin/: remove rails plugin dir. Message-ID: <20070615083013.D0BCA5240943@rubyforge.org> Revision: 241 Author: shino Date: 2007-06-15 04:30:10 -0400 (Fri, 15 Jun 2007) Log Message: ----------- remove rails plugin dir. it has been deprecated. Removed Paths: ------------- trunk/ap4r/rails_plugin/ From kato-k at rubyforge.org Fri Jun 22 05:53:47 2007 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Fri, 22 Jun 2007 05:53:47 -0400 (EDT) Subject: [ap4r-devel] [242] trunk/samples/HelloWorld/config/environment.rb: Removed require gruff. Message-ID: <20070622095347.6A5165240A7C@rubyforge.org> Revision: 242 Author: kato-k Date: 2007-06-22 05:53:46 -0400 (Fri, 22 Jun 2007) Log Message: ----------- Removed require gruff. Modified Paths: -------------- trunk/samples/HelloWorld/config/environment.rb Modified: trunk/samples/HelloWorld/config/environment.rb =================================================================== --- trunk/samples/HelloWorld/config/environment.rb 2007-06-15 08:30:10 UTC (rev 241) +++ trunk/samples/HelloWorld/config/environment.rb 2007-06-22 09:53:46 UTC (rev 242) @@ -58,5 +58,3 @@ # Mime::Type.register "application/x-mobile", :mobile # Include your application configuration below - -require 'gruff' From kato-k at rubyforge.org Fri Jun 22 06:13:03 2007 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Fri, 22 Jun 2007 06:13:03 -0400 (EDT) Subject: [ap4r-devel] [243] trunk/ap4r: Modified Rakefile with hoe. Message-ID: <20070622101303.C81475240AB4@rubyforge.org> Revision: 243 Author: kato-k Date: 2007-06-22 06:13:03 -0400 (Fri, 22 Jun 2007) Log Message: ----------- Modified Rakefile with hoe. Modified Paths: -------------- trunk/ap4r/Rakefile Added Paths: ----------- trunk/ap4r/History.txt trunk/ap4r/Manifest.txt trunk/ap4r/README.txt Removed Paths: ------------- trunk/ap4r/CHANGELOG trunk/ap4r/README Deleted: trunk/ap4r/CHANGELOG =================================================================== --- trunk/ap4r/CHANGELOG 2007-06-22 09:53:46 UTC (rev 242) +++ trunk/ap4r/CHANGELOG 2007-06-22 10:13:03 UTC (rev 243) @@ -1,40 +0,0 @@ -== 0.3.x - -=== 0.3.2 (June 7th, 2007) -* Fixed: util/loc.rb doesn't work. -* Changed: Argument order of async_dispatch has changed, backward INCOMPATIBLE. -* Added: Dynamic configuration with ERb. -* Added: Script to run AP4R on Mongrel. -* Changed: How to plugin and main API names have changed. -* Added: Support of several Content-type on asynchronous call. -* Added: Block style for async_to. -* Added: Url rewrite filter. - -=== 0.3.1 (April 24th, 2007) - -* Changed: @delete_mode of AsyncController to @@saf_delete_mode with accessor. -* Changed: default value of dispatch_mode, from :XMLRPC to :HTTP. -* Added: Bootstrap script to let ap4r run on mongrel, experimental yet. - -=== 0.3.0 (April 6th, 2007) - -* Changed: name space from "AP4R" to "Ap4r". -* Added: support the latest version for Ruby(1.8.6) and RubyGems(0.9.2) and Rails(1.2.3) . - -== 0.2.x - -=== 0.2.0 (October 17th, 2006) - -* Added: Protocols to invoke asynchronous logics. -* Added: At-lease-once QoS. - -== 0.1.x - -=== 0.1.1 (October 5th, 2006) - -* Changed: Enriched RDoc. -* Changed: Enriched README. - -=== 0.1.0 (September 1st, 2006) - -* Initial release. Added: trunk/ap4r/History.txt =================================================================== --- trunk/ap4r/History.txt (rev 0) +++ trunk/ap4r/History.txt 2007-06-22 10:13:03 UTC (rev 243) @@ -0,0 +1,43 @@ +== 0.3.x + +=== 0.3.3 (June ?, 2007) +* Added: support with hoe. + +=== 0.3.2 (June 7th, 2007) +* Fixed: util/loc.rb doesn't work. +* Changed: Argument order of async_dispatch has changed, backward INCOMPATIBLE. +* Added: Dynamic configuration with ERb. +* Added: Script to run AP4R on Mongrel. +* Changed: How to plugin and main API names have changed. +* Added: Support of several Content-type on asynchronous call. +* Added: Block style for async_to. +* Added: Url rewrite filter. + +=== 0.3.1 (April 24th, 2007) + +* Changed: @delete_mode of AsyncController to @@saf_delete_mode with accessor. +* Changed: default value of dispatch_mode, from :XMLRPC to :HTTP. +* Added: Bootstrap script to let ap4r run on mongrel, experimental yet. + +=== 0.3.0 (April 6th, 2007) + +* Changed: name space from "AP4R" to "Ap4r". +* Added: support the latest version for Ruby(1.8.6) and RubyGems(0.9.2) and Rails(1.2.3) . + +== 0.2.x + +=== 0.2.0 (October 17th, 2006) + +* Added: Protocols to invoke asynchronous logics. +* Added: At-lease-once QoS. + +== 0.1.x + +=== 0.1.1 (October 5th, 2006) + +* Changed: Enriched RDoc. +* Changed: Enriched README. + +=== 0.1.0 (September 1st, 2006) + +* Initial release. Added: trunk/ap4r/Manifest.txt =================================================================== --- trunk/ap4r/Manifest.txt (rev 0) +++ trunk/ap4r/Manifest.txt 2007-06-22 10:13:03 UTC (rev 243) @@ -0,0 +1,38 @@ +History.txt +MIT-LICENSE +Rakefile +README.txt +bin/ap4r_setup +config/ap4r_settings.rb +config/log4r.yaml +config/queues.cfg +config/queues_disk.cfg +config/queues_mysql.cfg +lib/ap4r.rb +lib/ap4r/carrier.rb +lib/ap4r/dispatcher.rb +lib/ap4r/message_store_ext.rb +lib/ap4r/mongrel.rb +lib/ap4r/mongrel_ap4r.rb +lib/ap4r/multi_queue.rb +lib/ap4r/queue_manager_ext.rb +lib/ap4r/queue_manager_ext_debug.rb +lib/ap4r/retention_history.rb +lib/ap4r/script/base.rb +lib/ap4r/script/queue_manager_control.rb +lib/ap4r/script/setup.rb +lib/ap4r/script/workspace_generator.rb +lib/ap4r/start_with_log4r.rb +lib/ap4r/store_and_forward.rb +lib/ap4r/stored_message.rb +lib/ap4r/util/irm.rb +lib/ap4r/util/queue_client.rb +lib/ap4r/version.rb +script/irm +script/loop.cmd +script/loop.rb +script/mongrel_ap4r +script/start +script/stop +spec/local/dispatcher_base_spec.rb +spec/spec_helper.rb Deleted: trunk/ap4r/README =================================================================== --- trunk/ap4r/README 2007-06-22 09:53:46 UTC (rev 242) +++ trunk/ap4r/README 2007-06-22 10:13:03 UTC (rev 243) @@ -1,55 +0,0 @@ -== What is AP4R? - -AP4R, Asynchronous Processing for Ruby, is the implementation of reliable asynchronous message processing. It provides message queuing, and message dispatching. -Using asynchronous processing, we can cut down turn-around-time of web applications by queuing, or can utilize more machine power by load-balancing. -Also AP4R nicely ties with your Ruby on Rails applications. See Hello World sample application from rubyforge. - -For more information, please step in AP4R homepage! - -http://ap4r.rubyforge.org/wiki/wiki.pl - -== Features - -1. Business logics can be implemented as simple Web applications, or ruby code, whether it's called asynchronously or synchronously. -1. Asynchronous messaging is reliable by RDBMS persistence (now MySQL only) or file persistence, under the favor of reliable-msg. -1. Load balancing over multiple AP4R processes on single/multiple servers is supported. -1. Asynchronous logics are called via various protocols, such as XML-RPC, SOAP, HTTP PUT, and more. -1. Using store and forward function, at-least-omce QoS level is provided. - -== Typical process flow - -1. A client(e.g. a web browser) makes a request to a web server (Apache, Lighttpd, etc...). -1. A rails application (a synchronous logic) is executed on mongrel via mod_proxy or something. -1. At the last of the synchronous logic, message(s) are put to AP4R (AP4R provides a helper). -1. Once the synchronous logic is done, the clients receives a response immediately. -1. AP4R queues the message, and requests it to the web server asynchronously. -1. An asynchronous logic, implemented as usual rails action, is executed. - - -== Installation - -Use RubyGems command. - - $ sudo gem install ap4r --include-dependencies - -== References - -* Ruby Homepage - * http://www.ruby-lang.org/ -* Ruby on Rails tutorial - * http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html -* MySQL tutorial - * http://dev.mysql.com/doc/refman/5.0/en/index.html -* reliable-msg - * http://trac.labnotes.org/cgi-bin/trac.cgi/wiki/Ruby/ReliableMessaging - -== Licence - -This licence is licensed under the MIT license. -Copyright(c) 2007 Future Architect Inc. - -== Authors - -* Kiwamu Kato -* Shunichi Shinohara - Added: trunk/ap4r/README.txt =================================================================== --- trunk/ap4r/README.txt (rev 0) +++ trunk/ap4r/README.txt 2007-06-22 10:13:03 UTC (rev 243) @@ -0,0 +1,82 @@ +Ap4r +* by Kiwamu Kato, Shun'ichi Shinohara +* http://ap4r.rubyforge.org/wiki/wiki.pl?HomePage +* ap4r-user at rubyforge.org + +== DESCRIPTION: + +AP4R, Asynchronous Processing for Ruby, is the implementation of reliable asynchronous message processing. It provides message queuing, and message dispatching. +Using asynchronous processing, we can cut down turn-around-time of web applications by queuing, or can utilize more machine power by load-balancing. +Also AP4R nicely ties with your Ruby on Rails applications. See Hello World sample application from rubyforge. + +For more information, please step in AP4R homepage! + + +== FEATURES/PROBLEMS: + +* Business logics can be implemented as simple Web applications, or ruby code, whether it's called asynchronously or synchronously. +* Asynchronous messaging is reliable by RDBMS persistence (now MySQL only) or file persistence, under the favor of reliable-msg. +* Load balancing over multiple AP4R processes on single/multiple servers is supported. +* Asynchronous logics are called via various protocols, such as XML-RPC, SOAP, HTTP PUT, and more. +* Using store and forward function, at-least-omce QoS level is provided. + +== TYPICAL PROCESS FLOW: + +1. A client(e.g. a web browser) makes a request to a web server (Apache, Lighttpd, etc...). +1. A rails application (a synchronous logic) is executed on mongrel via mod_proxy or something. +1. At the last of the synchronous logic, message(s) are put to AP4R (AP4R provides a helper). +1. Once the synchronous logic is done, the clients receives a response immediately. +1. AP4R queues the message, and requests it to the web server asynchronously. +1. An asynchronous logic, implemented as usual rails action, is executed. + + +== SYNOPSIS: + +* FIX (code sample of usage) + +== REQUIREMENTS: + +* FIX (list of requirements) + +== INSTALL: + +Use RubyGems command. + + $ sudo gem install ap4r --include-dependencies + + +== REFERENCES: + +* Ruby Homepage + * http://www.ruby-lang.org/ +* Ruby on Rails tutorial + * http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html +* MySQL tutorial + * http://dev.mysql.com/doc/refman/5.0/en/index.html +* reliable-msg + * http://trac.labnotes.org/cgi-bin/trac.cgi/wiki/Ruby/ReliableMessaging + + +== LICENSE: + +* This licence is licensed under the MIT license. +* Copyright(c) 2007 Future Architect Inc. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Modified: trunk/ap4r/Rakefile =================================================================== --- trunk/ap4r/Rakefile 2007-06-22 09:53:46 UTC (rev 242) +++ trunk/ap4r/Rakefile 2007-06-22 10:13:03 UTC (rev 243) @@ -1,102 +1,70 @@ -# Author:: Kiwamu Kato -# Copyright:: Copyright (c) 2007 Future Architect Inc. -# Licence:: MIT Licence - -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' -require 'rake/gempackagetask' -require 'rake/contrib/rubyforgepublisher' - -require 'date' -require 'find' -require 'rbconfig' - +require 'rubygems' +require 'hoe' require File.join(File.dirname(__FILE__), 'lib/ap4r', 'version') -PKG_VERSION = Ap4r::VERSION::STRING +HelloWorld = '../samples/HelloWorld' -TEMP_DIR = './temp' -PKG_DIR = './pkg' -RELEASE_DIR = './release' -HELLO_WORLD_DIR = '../samples/HelloWorld' +# AP4R release tasks -------------------------------------------------------- -# Generate GEM ---------------------------------------------------------------------------- +# copy rails plugin from sample before gem build +FileUtils.mkdir_p('./rails_plugin/ap4r/lib') +FileUtils.cp(HelloWorld + '/db/migrate/001_create_table_for_saf.rb', './lib/ap4r/') +FileUtils.cp(HelloWorld + '/vendor/plugins/ap4r/init.rb', './rails_plugin/ap4r/') +FileUtils.cp(HelloWorld + '/vendor/plugins/ap4r/lib/async_helper.rb', './rails_plugin/ap4r/lib/') +FileUtils.cp(HelloWorld + '/vendor/plugins/ap4r/lib/ap4r_client.rb', './rails_plugin/ap4r/lib/') +FileUtils.cp(HelloWorld + '/vendor/plugins/ap4r/lib/message_builder.rb', './rails_plugin/ap4r/lib/') - -PKG_FILES = FileList[ - '[a-zA-Z]*', - 'bin/**/*', - 'config/**/*', - 'rails_plugin/**/*', - 'script/**/*', - 'lib/**/*' -] - -HELLO_WORLD_SAMPLE_FILES = FileList[ - '[a-zA-Z]*', - 'app/**/*', - 'components/**/*', - 'config/**/*', - 'db/**/*', - 'doc/**/*', - 'lib/**/*', - 'log/**/*', - 'public/**/*', - 'script/**/*', - 'test/**/*', - 'tmp/**/*', - 'vendor/**/*', -] - - -spec = Gem::Specification.new do |s| - s.name = 'ap4r' - s.version = PKG_VERSION - s.summary = "Asynchronous Processing for Ruby." - s.description = <<-EOF +Hoe.new('ap4r', Ap4r::VERSION::STRING) do |p| + p.author = ["Shunichi Shinohara", "Kiwamu Kato"] + p.changes = p.paragraphs_of('History.txt', 1..2).join("\n\n") + #p.clean_globs = + p.description = <<-EOF Asynchronous Processing for Ruby. EOF + p.email = %q{shinohara.shunichi at future.co.jp, kato.kiwamu at future.co.jp} - s.add_dependency(%q, ["= 1.1.0"]) - s.add_dependency(%q) - s.add_dependency(%q) - s.add_dependency(%q) + p.extra_deps << ['reliable-msg', '=1.1.0'] + p.extra_deps << ['activesupport'] + p.extra_deps << ['mongrel'] + p.extra_deps << ['rake'] + p.extra_deps << ['hoe'] - s.has_rdoc = true - s.extra_rdoc_files = ["README", "CHANGELOG", 'rails_plugin'] - s.rdoc_options << "--main" << "README" - s.rdoc_options << "--title" << "Asynchronous Processing for Ruby" - s.rdoc_options << "--line-numbers" + p.name = 'ap4r' + p.need_tar = false + p.need_zip = false + #p.rdoc_pattern = + #p.remote_rdoc_dir = + #p.rsync = + p.rubyforge_name = 'ap4r' + #p.spec_extra = + p.summary = 'Asynchronous Processing for Ruby.' + p.test_globs = 'spec/**/*_spec.rb' + p.url = 'http://ap4r.rubyforge.org/wiki/wiki.pl?HomePage' + p.version = Ap4r::VERSION::STRING +end - s.files = PKG_FILES.to_a.delete_if {|f| f.include?('.svn')} - s.require_path = 'lib' - s.autorequire = %q{ap4r.rb} +# Sample release tasks ------------------------------------------------------ +desc 'Make samle tarball (Now only HelloWorld sample).' +task :sample do + FileUtils.mkdir_p('./pkg/samples') + FileUtils.rm_rf('./pkg/samples/HelloWorld') + + FileUtils.cp_r(HelloWorld, './pkg/samples/') + Find.find('./pkg/samples') do |path| + next unless File.file? path + FileUtils.rm_rf(path) if path =~ /\.svn|tmp$|CVS|.rb\~/ + end - s.bindir = "bin" # Use these for applications. - s.executables = ["ap4r_setup"] - s.default_executable = "ap4r_setup" - - s.authors = ["Shunichi Shinohara", "Kiwamu Kato"] - s.email = %q{shinohara.shunichi at future.co.jp, kato.kiwamu at future.co.jp} - s.homepage = %q{http://rubyforge.org/projects/ap4r/} - s.rubyforge_project = "ap4r" + Dir.chdir('./pkg/samples/HelloWorld') + `rake db:migrate` + Dir.chdir('../../') + + `tar czvf HelloWorld-#{Ap4r::VERSION::STRING}.tar.gz ./samples/HelloWorld/` + Dir.chdir('../') end -Rake::GemPackageTask.new(spec) do |pkg| -end -# Generate documentation ------------------------------------------------------------------ - -Rake::RDocTask.new { |rdoc| - rdoc.rdoc_dir = 'doc' - rdoc.options << '--line-numbers' << '--inline-source' << '--accessor' << 'cattr_accessor=rw' - rdoc.rdoc_files.include('README', 'CHANGELOG') - rdoc.rdoc_files.include('lib/**/*.rb') - rdoc.rdoc_files.include('rails_plugin/**/*.rb') -} - # Spec tasks ---------------------------------------------------------------- require 'spec/rake/spectask' @@ -123,71 +91,7 @@ end end -# AP4R release ---------------------------------------------------------------- -desc "Make gem" -task :gem_release => [ :make_release_dir, :copy_to_ap4r_from_sample, :gem] - -task :copy_to_ap4r_from_sample do - FileUtils.cp(HELLO_WORLD_DIR + '/db/migrate/001_create_table_for_saf.rb', './lib/ap4r/xxx_create_table_for_saf.rb') - - FileUtils.cp(HELLO_WORLD_DIR + '/vendor/plugins/ap4r/init.rb', './rails_plugin/ap4r/init.rb') - FileUtils.cp(HELLO_WORLD_DIR + '/vendor/plugins/ap4r/lib/async_helper.rb', './rails_plugin/ap4r/lib/async_helper.rb') - FileUtils.cp(HELLO_WORLD_DIR + '/vendor/plugins/ap4r/lib/ap4r_client.rb', './rails_plugin/ap4r/lib/ap4r_client.rb') - FileUtils.cp(HELLO_WORLD_DIR + '/vendor/plugins/ap4r/lib/message_builder.rb', './rails_plugin/ap4r/lib/message_builder.rb') -end - -desc "Make sample tgz" -task :sample_release => [ :make_release_dir, :make_sample_tgz, :copy_to_release_dir ] - -task :make_sample_tgz => [ :make_temp_dir, :copy_sample, :execute_migration, :make_tgz ] - -task :make_release_dir do - make_dir RELEASE_DIR -end - -task :make_temp_dir do - make_dir TEMP_DIR -end - -def make_dir(path) - if(File.exist?(path)) - FileUtils.remove_entry(path, true) - end - FileUtils.mkdir_p(path) -end - - -task :copy_sample do - FileUtils.cp_r(HELLO_WORLD_DIR, TEMP_DIR) - Find.find(TEMP_DIR) {|f| - if f.include?('.svn') - FileUtils.rm_rf(f) - end - } -end - -task :execute_migration do - Dir.chdir('temp/HelloWorld') - `rake db:migrate` - Dir.chdir('../../') -end - -task :make_tgz do - Dir.chdir('temp/') - `tar czvf HelloWorld.tar.gz HelloWorld/` - Dir.chdir('../') -end - -task :copy_to_release_dir do - Dir.foreach(PKG_DIR) {|f| - FileUtils.cp(PKG_DIR + '/' + f, RELEASE_DIR) if File.fnmatch("*.gem", f) - } - Dir.foreach(TEMP_DIR) {|f| - FileUtils.cp(TEMP_DIR + '/' + f, RELEASE_DIR) if File.fnmatch("*.tar.gz", f) - } -end - # AP4R misc tools ---------------------------------------------------------------- desc "display code statistics" From shino at rubyforge.org Sun Jun 24 20:28:52 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Sun, 24 Jun 2007 20:28:52 -0400 (EDT) Subject: [ap4r-devel] [244] trunk/ap4r/README.txt: FIXED: typos Message-ID: <20070625002852.366EB5240A6F@rubyforge.org> Revision: 244 Author: shino Date: 2007-06-24 20:28:47 -0400 (Sun, 24 Jun 2007) Log Message: ----------- FIXED: typos Modified Paths: -------------- trunk/ap4r/README.txt Modified: trunk/ap4r/README.txt =================================================================== --- trunk/ap4r/README.txt 2007-06-22 10:13:03 UTC (rev 243) +++ trunk/ap4r/README.txt 2007-06-25 00:28:47 UTC (rev 244) @@ -18,11 +18,11 @@ * Asynchronous messaging is reliable by RDBMS persistence (now MySQL only) or file persistence, under the favor of reliable-msg. * Load balancing over multiple AP4R processes on single/multiple servers is supported. * Asynchronous logics are called via various protocols, such as XML-RPC, SOAP, HTTP PUT, and more. -* Using store and forward function, at-least-omce QoS level is provided. +* Using store and forward function, at-least-once QoS level is provided. == TYPICAL PROCESS FLOW: -1. A client(e.g. a web browser) makes a request to a web server (Apache, Lighttpd, etc...). +1. A client (e.g. a web browser) makes a request to a web server (Apache, Lighttpd, etc...). 1. A rails application (a synchronous logic) is executed on mongrel via mod_proxy or something. 1. At the last of the synchronous logic, message(s) are put to AP4R (AP4R provides a helper). 1. Once the synchronous logic is done, the clients receives a response immediately. @@ -59,7 +59,7 @@ == LICENSE: -* This licence is licensed under the MIT license. +* This software is licensed under the MIT license. * Copyright(c) 2007 Future Architect Inc. Permission is hereby granted, free of charge, to any person obtaining From kato-k at rubyforge.org Mon Jun 25 03:44:30 2007 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Mon, 25 Jun 2007 03:44:30 -0400 (EDT) Subject: [ap4r-devel] [245] trunk/ap4r: Added create_manifest task. Message-ID: <20070625074430.6214B5240BAA@rubyforge.org> Revision: 245 Author: kato-k Date: 2007-06-25 03:44:28 -0400 (Mon, 25 Jun 2007) Log Message: ----------- Added create_manifest task. Modified Paths: -------------- trunk/ap4r/Manifest.txt trunk/ap4r/Rakefile Modified: trunk/ap4r/Manifest.txt =================================================================== --- trunk/ap4r/Manifest.txt 2007-06-25 00:28:47 UTC (rev 244) +++ trunk/ap4r/Manifest.txt 2007-06-25 07:44:28 UTC (rev 245) @@ -1,7 +1,8 @@ History.txt MIT-LICENSE +Manifest.txt +README.txt Rakefile -README.txt bin/ap4r_setup config/ap4r_settings.rb config/log4r.yaml @@ -9,6 +10,7 @@ config/queues_disk.cfg config/queues_mysql.cfg lib/ap4r.rb +lib/ap4r/001_create_table_for_saf.rb lib/ap4r/carrier.rb lib/ap4r/dispatcher.rb lib/ap4r/message_store_ext.rb @@ -28,6 +30,10 @@ lib/ap4r/util/irm.rb lib/ap4r/util/queue_client.rb lib/ap4r/version.rb +rails_plugin/ap4r/init.rb +rails_plugin/ap4r/lib/ap4r_client.rb +rails_plugin/ap4r/lib/async_helper.rb +rails_plugin/ap4r/lib/message_builder.rb script/irm script/loop.cmd script/loop.rb Modified: trunk/ap4r/Rakefile =================================================================== --- trunk/ap4r/Rakefile 2007-06-25 00:28:47 UTC (rev 244) +++ trunk/ap4r/Rakefile 2007-06-25 07:44:28 UTC (rev 245) @@ -44,6 +44,27 @@ end +desc 'Create Manifest.txt' +task :create_manifest do + + path_list = [] + Find.find('.') do |path| + next unless File.file? path + next if path =~ /\.svn|tmp$|CVS|.rb\~/ + path_list << path + end + + File.open('Manifest.txt', 'w') do |manifest| + path_list.sort.each do |path| + /.\// =~ path + manifest.puts($~.post_match) + end + end + +end + + + # Sample release tasks ------------------------------------------------------ desc 'Make samle tarball (Now only HelloWorld sample).' task :sample do From kato-k at rubyforge.org Tue Jun 26 03:46:16 2007 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Tue, 26 Jun 2007 03:46:16 -0400 (EDT) Subject: [ap4r-devel] [246] trunk/samples/HelloWorld: Added hoe support to HelloWorld sample. Message-ID: <20070626074616.609845240BE2@rubyforge.org> Revision: 246 Author: kato-k Date: 2007-06-26 03:46:15 -0400 (Tue, 26 Jun 2007) Log Message: ----------- Added hoe support to HelloWorld sample. Modified Paths: -------------- trunk/samples/HelloWorld/Rakefile Added Paths: ----------- trunk/samples/HelloWorld/History.txt trunk/samples/HelloWorld/Manifest.txt trunk/samples/HelloWorld/README.txt Added: trunk/samples/HelloWorld/History.txt =================================================================== --- trunk/samples/HelloWorld/History.txt (rev 0) +++ trunk/samples/HelloWorld/History.txt 2007-06-26 07:46:15 UTC (rev 246) @@ -0,0 +1,5 @@ +== 1.0.0 / 2007-06-25 + +* 1 major enhancement + * Birthday! + Added: trunk/samples/HelloWorld/Manifest.txt =================================================================== --- trunk/samples/HelloWorld/Manifest.txt (rev 0) +++ trunk/samples/HelloWorld/Manifest.txt 2007-06-26 07:46:15 UTC (rev 246) @@ -0,0 +1,92 @@ +History.txt +Manifest.txt +README +README.txt +Rakefile +app/apis/async_world_api.rb +app/controllers/application.rb +app/controllers/async_shop_controller.rb +app/controllers/async_world_controller.rb +app/controllers/msg_retention_controller.rb +app/controllers/saf_controller.rb +app/controllers/shop_controller.rb +app/controllers/sync_hello_controller.rb +app/helpers/application_helper.rb +app/helpers/async_shop_helper.rb +app/helpers/async_world_helper.rb +app/helpers/msg_retention_helper.rb +app/helpers/saf_helper.rb +app/helpers/shop_helper.rb +app/helpers/sync_hello_helper.rb +app/models/ap4r_class.rb +app/models/ap4r_group.rb +app/models/world_request.rb +app/views/async_world/execute.rhtml +app/views/layouts/application.rhtml +app/views/layouts/saf.rhtml +app/views/msg_retention/load2replace_by_js.rhtml +app/views/msg_retention/retention.rhtml +app/views/msg_retention/status_img.rhtml +app/views/saf/_form.rhtml +app/views/saf/edit.rhtml +app/views/saf/list.rhtml +app/views/saf/new.rhtml +app/views/saf/show.rhtml +app/views/shop/account.rhtml +app/views/shop/order.rhtml +app/views/sync_hello/index.rhtml +config/ap4r.yml.sample +config/boot.rb +config/database.yml +config/environment.rb +config/environments/development.rb +config/environments/production.rb +config/environments/test.rb +config/mongrel_cluster.yml +config/routes.rb +db/hello_world_development.db +db/hello_world_production.db +db/migrate/001_create_table_for_saf.rb +db/schema.rb +public/.htaccess +public/404.html +public/500.html +public/dispatch.cgi +public/dispatch.fcgi +public/dispatch.rb +public/favicon.ico +public/images/rails.png +public/javascripts/application.js +public/javascripts/controls.js +public/javascripts/dragdrop.js +public/javascripts/effects.js +public/javascripts/prototype.js +public/public_original.html +public/robots.txt +public/stylesheets/scaffold.css +script/about +script/breakpointer +script/console +script/destroy +script/generate +script/performance/benchmarker +script/performance/profiler +script/plugin +script/process/inspector +script/process/reaper +script/process/spawner +script/runner +script/server +test/async/ap4r_test_helper.rb +test/async/hello_world_stories_test.rb +test/functional/async_shop_controller_test.rb +test/functional/msg_retention_controller_test.rb +test/functional/shop_controller_test.rb +test/integration/ap4r_queue_stub.rb +test/integration/hello_rails_integration_with_ap4r_test.rb +test/test_helper.rb +tmp/sessions/hoge.txt +vendor/plugins/ap4r/init.rb +vendor/plugins/ap4r/lib/ap4r_client.rb +vendor/plugins/ap4r/lib/async_helper.rb +vendor/plugins/ap4r/lib/message_builder.rb Added: trunk/samples/HelloWorld/README.txt =================================================================== --- trunk/samples/HelloWorld/README.txt (rev 0) +++ trunk/samples/HelloWorld/README.txt 2007-06-26 07:46:15 UTC (rev 246) @@ -0,0 +1,48 @@ +HelloWorld + by FIX (your name) + FIX (url) + +== DESCRIPTION: + +FIX (describe your package) + +== FEATURES/PROBLEMS: + +* FIX (list of features or problems) + +== SYNOPSIS: + + FIX (code sample of usage) + +== REQUIREMENTS: + +* FIX (list of requirements) + +== INSTALL: + +* FIX (sudo gem install, anything else) + +== LICENSE: + +(The MIT License) + +Copyright (c) 2007 FIX + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Modified: trunk/samples/HelloWorld/Rakefile =================================================================== --- trunk/samples/HelloWorld/Rakefile 2007-06-25 07:44:28 UTC (rev 245) +++ trunk/samples/HelloWorld/Rakefile 2007-06-26 07:46:15 UTC (rev 246) @@ -1,10 +1,95 @@ -# Add your own tasks in files placed in lib/tasks ending in .rake, -# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. +require 'rubygems' +require 'hoe' -require(File.join(File.dirname(__FILE__), 'config', 'boot')) +require File.join(File.dirname(__FILE__), 'config', 'boot') +require 'tasks/rails' -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' +VERSION = '0.3.3' -require 'tasks/rails' +# HelloWorld release tasks -------------------------------------------------------- + +Hoe.new('HelloWorld', VERSION) do |p| + p.author = ["Shunichi Shinohara", "Kiwamu Kato"] + p.changes = p.paragraphs_of('History.txt', 1..2).join("\n\n") + #p.clean_globs = + p.description = <<-EOF + One of AP4R's sample applications. + EOF + p.email = %q{shinohara.shunichi at future.co.jp, kato.kiwamu at future.co.jp} + + #p.extra_deps << + p.name = 'HelloWorld' + p.need_tar = false + p.need_zip = false + #p.rdoc_pattern = + #p.remote_rdoc_dir = + #p.rsync = + p.rubyforge_name = 'ap4r' + #p.spec_extra = + p.summary = 'One of AP4Rs sample applications' + #p.test_globs = 'test/**/*_test.rb' + p.url = 'http://ap4r.rubyforge.org/wiki/wiki.pl?HomePage' + p.version = VERSION +end + + +desc 'Create Manifest.txt' +task :create_manifest do + path_list = [] + Find.find('.') do |path| + next unless File.file? path + next if path =~ /\.svn|tmp$|CVS|.rb\~|.log|.pid/ + path_list << path + end + + File.open('Manifest.txt', 'w') do |manifest| + path_list.sort.each do |path| + /.\// =~ path + manifest.puts($~.post_match) + end + end +end + + +# Sample release tasks ------------------------------------------------------ +desc 'Create sample HelloWorld tarball' +task :tar do + + FileUtils.mkdir_p('../temp/samples/HelloWorld') + FileUtils.rm_rf('../temp/samples/HelloWorld') + + FileUtils.cp_r('.', '../temp/samples/HelloWorld') + Find.find('../temp/samples') do |path| + next unless File.file? path + FileUtils.rm_rf(path) if path =~ /\.svn|tmp$|CVS|.rb\~|.log|.pid/ + end + + FileUtils.mkdir_p('./pkg') + FileUtils.cp_r('../temp/samples/HelloWorld','./pkg') + FileUtils.rm_rf('../temp') + + Dir.chdir('./pkg/HelloWorld') + `rake db:migrate` + Dir.chdir('../') + + sh "tar czf HelloWorld-#{VERSION}.tar.gz ./HelloWorld/" + Dir.chdir('../') + +end + + +# misc tools ---------------------------------------------------------------- + +desc "display code statistics" +task :stats do + require 'rubygems' + require 'active_support' + require 'code_statistics' + CodeStatistics::TEST_TYPES.concat(["Local specs"]) + CodeStatistics.new( + ["Core Sources", "lib"], + ["Rails plugin", "rails_plugin"], + ["Scripts", "script"], + ["Local specs", "spec/local"] + ).to_s +end