From f92fe7786d1d8d1c74802f28eaa3dd39d7656b4c Mon Sep 17 00:00:00 2001 From: JT Smith Date: Thu, 1 Feb 2007 21:50:47 +0000 Subject: [PATCH] - Added a basic status interface to spectre, for troubleshooting. --- docs/changelog/7.x.x.txt | 1 + lib/Spectre/Workflow.pm | 72 ++++++++++++++++++++++++---------------- 2 files changed, 45 insertions(+), 28 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index b885f2214..2a93bf9a6 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -21,6 +21,7 @@ - Simplified Spectre's initial data load, and reduced memory footprint in the process. - fix: Spectre needs to be restarted every day + - Added a basic status interface to spectre, for troubleshooting. - fix: lack of testing for valid object creation - fix: No mention of intermediate upgrade step in gotcha's - fix: A newly released version of Html::Template fixes a bug with global diff --git a/lib/Spectre/Workflow.pm b/lib/Spectre/Workflow.pm index edceafe9b..4b7898d32 100644 --- a/lib/Spectre/Workflow.pm +++ b/lib/Spectre/Workflow.pm @@ -207,33 +207,6 @@ sub getLogger { return $self->{_logger}; } -#------------------------------------------------------------------- - -=head2 getRunningQueue ( ) - -Returns a reference to the queue of workflow instances that are running now. - -=cut - -sub getRunningQueue { - my $self = shift; - return $self->{_runningQueue}; -} - -#------------------------------------------------------------------- - -=head2 getWaitingQueue ( ) - -Returns a reference to the queue of workflow instances waiting to run. - -=cut - -sub getWaitingQueue { - my $self = shift; - return $self->{_waitingQueue}; -} - - #------------------------------------------------------------------- =head2 getNextInstance ( ) @@ -257,6 +230,49 @@ sub getNextInstance { return undef; } +#------------------------------------------------------------------- + +=head2 getRunningQueue ( ) + +Returns a reference to the queue of workflow instances that are running now. + +=cut + +sub getRunningQueue { + my $self = shift; + return $self->{_runningQueue}; +} + +#------------------------------------------------------------------- + +=head2 getStatus ( ) + +Returns a formatted text status report about the workflow engine. + +=cut + +sub getStatus { + my ($kernel, $request, $self) = @_[KERNEL,ARG0,OBJECT]; + my $output = "Running Workflows: ".$self->getRunningQueue->get_item_count."\n"; + $output .= "Workflows Waiting To Run: ".$self->getWaitingQueue->get_item_count."\n"; + my ($data, $rsvp) = @$request; + $kernel->call(IKC=>post=>$rsvp,$output); +} + +#------------------------------------------------------------------- + +=head2 getWaitingQueue ( ) + +Returns a reference to the queue of workflow instances waiting to run. + +=cut + +sub getWaitingQueue { + my $self = shift; + return $self->{_waitingQueue}; +} + + #------------------------------------------------------------------- =head2 new ( config, logger, [ , debug ] ) @@ -284,7 +300,7 @@ sub new { my $debug = shift; my $self = {_debug=>$debug, _config=>$config, _logger=>$logger}; bless $self, $class; - my @publicEvents = qw(addInstance deleteInstance); + my @publicEvents = qw(addInstance deleteInstance getStatus); POE::Session->create( object_states => [ $self => [qw(_start _stop returnInstanceToRunnableState addInstance checkInstances deleteInstance suspendInstance runWorker workerResponse), @publicEvents] ], args=>[\@publicEvents]