Hi pileofrogs,

I like the idea, definitely. I get swamped with pages/error emails/you name it on occasion, and would love a good solution to that problem. I was actually a bit surprised I couldn't find anything on CPAN that already does this, so yes, please, build this *now* :)

As for the name, TimeLock doesn't really explain what it does. I'm not really good with names, but maybe something like "Sub::Deferred" would be clearer.

I feel your interface is too verbose, and interferes with the flow of the code. I would recommend an interface like Memoize, in that you "defer" a function or method somewhere at the top of your script, while the rest of your code stays as is:

use Sub::Deferred store => '/tmp/foo_timelock'; defer( 'page_me', 600 ); # ... if( something_really_bad() ) { my $message = "Something Really Bad just happened..."; page_me( $message ); # run only once every 600 seconds }

This way you could add it to existing scripts without having to go through a lot of code. And it's very easy to disable too.

It would probably be quite easy to decide to defer a subroutine based on its input parameters. Strategies and settings could be specified in the call to defer().


In reply to Re: RFC: Time Lock Module Idea? by rhesa
in thread RFC: Time Lock Module Idea? by pileofrogs

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.