Peter Farmer wrote:
Hi all,

I'm trying to write my application with as much fault tolerance as
possible, with that is mind, is if acceptable for a sessions _start
subroutine to call:

$kernel->delay_set("_start", 60);

obviously the _start subroutine will have some logic to prevent it
from running any of the "work" subroutines.

The basic idea is that if _start can't initialise the session because
a database connection fails (for example), it can try again after a
set period of time, and 1. it doesn't stop the kernel, and 2. it
doesn't stop other sessions from running etc....


Thanks,
I think a more cleaner design would be to separate the initialization of the session from the creation ->

sub _start : state {
   # Your session start-up code here

   # Then, we defer to the init routine
   $_[KERNEL]->yield( 'init' );
}

sub init :state {
   # Do our initialization here

   # Did we successfully init?
   if ( ! $success ) {
      $_[KERNEL]->delay_set( 'init', 60 );
   }
}

That's just my school of thought, feel free to use your design, I think it's rather clever but not that obvious :)

P.S. In case you haven't seen the :state thing -> POE::Session::AttributeBased

--
Apocalypse

Homepage:       http://JiNxEdStAr.0ne.us
IRC:            [EMAIL PROTECTED]
IRC:            [EMAIL PROTECTED]
Perl Stuff:     http://search.cpan.org/~APOCAL/

Reply via email to