Tidy up docs, MANIFEST etc.
Chris Andrews [Sat, 16 May 2009 20:42:53 +0000 (21:42 +0100)]
.gitignore
Changes
MANIFEST
README
lib/Catalyst/Controller/MessageDriven.pm
lib/Catalyst/Engine/Stomp.pm

index 50f042c..cf38d51 100644 (file)
@@ -1,4 +1,5 @@
 MANIFEST
+MANIFEST.bak
 META.yml
 Makefile
 Makefile.old
@@ -6,3 +7,4 @@ blib
 inc
 pm_to_blib
 *~
+Catalyst-Engine-Stomp-*
diff --git a/Changes b/Changes
index 958f7e6..79e137e 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,6 +1,4 @@
 Revision history for Perl extension Catalyst::Engine::Stomp.
 
-0.01  Tue Dec 16 10:15:20 2008
-       - original version; created by h2xs 1.23 with options
-               -n Catalyst::Engine::Stomp
-
+0.01  Fri May 15 21:39:30 2009
+       Initial CPAN Release
index 245cfe2..b959a2c 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -1,12 +1,25 @@
 Changes
+inc/Module/AutoInstall.pm
+inc/Module/Install.pm
+inc/Module/Install/AutoInstall.pm
+inc/Module/Install/Base.pm
+inc/Module/Install/Can.pm
+inc/Module/Install/Fetch.pm
+inc/Module/Install/Include.pm
+inc/Module/Install/Makefile.pm
+inc/Module/Install/Metadata.pm
+inc/Module/Install/Win32.pm
+inc/Module/Install/WriteAll.pm
+lib/Catalyst/Controller/MessageDriven.pm
+lib/Catalyst/Engine/Stomp.pm
 Makefile.PL
-MANIFEST
+MANIFEST                       This list of files
+META.yml
 README
+t/00_use.t
 t/Catalyst-Engine-Stomp.t
-lib/Catalyst/Engine/Stomp.pm
-lib/Catalyst/Controller/MessageDriven.pm
+testapp/lib/TestApp.pm
 testapp/lib/TestApp/Controller/TestController.pm
 testapp/lib/TestApp/testapp.yml
-testapp/lib/TestApp.pm
 testapp/script/testapp_stomp.pl
-
+testapp/script/testapp_stomp_workers.pl
diff --git a/README b/README
index 37e8b5a..ca4cc2d 100644 (file)
--- a/README
+++ b/README
@@ -20,9 +20,15 @@ DEPENDENCIES
 
 This module requires these other modules and libraries:
 
+     Moose
      Net::Stomp
      YAML::XS
+     Catalyst::Engine::Embeddable
      Catalyst::Runtime 5.80003
+     Catalyst::Action::REST
+     namespace::autoclean
+     
+The supplied workers script requires MooseX::Workers.
 
 COPYRIGHT AND LICENCE
 
index fba221d..0c00a8d 100644 (file)
@@ -3,6 +3,31 @@ use Moose;
 
 BEGIN { extends 'Catalyst::Controller' }
 
+=head1 NAME
+
+Catalyst::Controller::MessageDriven
+
+=head1 SYNOPSIS
+
+  package MyApp::Controller::Queue;
+  use Moose;
+  BEGIN { extends 'Catalyst::Controller::MessageDriven' }
+
+  sub some_action : Local { 
+      my ($self, $c) = @_;
+      # Reply with a minimal response message
+      my $response = { type => 'testaction_response' };
+      $c->stash->{response} = $response;
+  }
+
+=head1 DESCRIPTION
+
+A Catalyst controller base class for use with Catalyst::Engine::Stomp,
+which handles YAML-serialized messages. A top-level "type" key in the
+YAML determines the action dispatched to. 
+
+=cut
+
 __PACKAGE__->config(
                    'default'   => 'text/x-yaml',
                    'stash_key' => 'response',
index e6580f6..4391d9a 100644 (file)
@@ -32,30 +32,25 @@ Catalyst::Engine::Stomp - write message handling apps with Catalyst.
   MyApp->run();
 
   # In a controller, or controller base class:
+  use base qw/ Catalyst::Controller::MessageDriven /;
 
-  use YAML;
+  # then create actions, which map as message types
+  sub testaction : Local {
+      my ($self, $c) = @_;
 
-  # configure YAML deserialization; requires Catalyst::Action::REST
+      # Reply with a minimal response message
+      my $response = { type => 'testaction_response' };
+      $c->stash->{response} = $response;
+  }
+
+  # The default serialization is YAML, but this configuration 
+  # may be overridden in your controller:
   __PACKAGE__->config(
                    'default'   => 'text/x-yaml',
                    'stash_key' => 'rest',
                    'map'       => { 'text/x-yaml' => 'YAML' },
                   );
 
-  sub begin :ActionClass('Deserialize') { }
-
-  # have a default action, which forwards to the correct action
-  # based on the message contents (the type).
-  sub default : Private {
-         my ($self, $c) = @_;
-
-         my $action = $c->req->data->{type};
-         $c->forward($action);
-  }  
-
-  # Send messages back:
-  $c->engine->send_message($queue, Dump($msg));
-
 =head1 DESCRIPTION
 
 Write a Catalyst app connected to a Stomp messagebroker, not HTTP. You
@@ -65,6 +60,11 @@ This is single-threaded and single process - you need to run multiple
 instances of this engine to get concurrency, and configure your broker
 to load-balance across multiple consumers of the same queue.
 
+Controllers are mapped to Stomp queues, and a controller base class is
+provided, Catalyst::Controller::MessageDriven, which implements
+YAML-serialized messages, mapping a top-level YAML "type" key to 
+the action. 
+
 =head1 METHODS
 
 =head2 run
@@ -133,7 +133,8 @@ sub prepare_request {
 
 =head2 finalize_headers
 
-Overridden to dump out any errors encountered.
+Overridden to dump out any errors encountered, since you won't get a
+"debugging" message as for HTTP.
 
 =cut
 
@@ -148,7 +149,7 @@ sub finalize_headers {
 
 =head2 handle_stomp_frame
 
-Dispatch according to STOMP frame type.
+Dispatch according to Stomp frame type.
 
 =cut
 
@@ -163,13 +164,13 @@ sub handle_stomp_frame {
                $self->handle_stomp_error($app, $frame);
        }
        else {
-               $app->log->debug("Got unknown STOMP command: $command");
+               $app->log->debug("Got unknown Stomp command: $command");
        }
 }
 
 =head2 handle_stomp_message
 
-Dispatch a STOMP message into the Catalyst app.
+Dispatch a Stomp message into the Catalyst app.
 
 =cut
 
@@ -201,7 +202,7 @@ sub handle_stomp_message {
 
 =head2 handle_stomp_error
 
-Log any STOMP error frames we receive.
+Log any Stomp error frames we receive.
 
 =cut
 
@@ -209,8 +210,10 @@ sub handle_stomp_error {
        my ($self, $app, $frame) = @_;
        
        my $error = $frame->headers->{message};
-       $app->log->debug("Got STOMP error: $error");
+       $app->log->debug("Got Stomp error: $error");
 }
 
+__PACKAGE__->meta->make_immutable;
+
 1;