NAME

Argon::Util - Utilities used in Argon classes

VERSION

version 0.18

DESCRIPTION

Utility functions used in Argon classes.

EXPORTS

No subroutines are exported by default.

SUBROUTINES

K

Creates a callback function that calls a method on an object instance with arbitrary arguments while preventing circular references from closing over the method or object instance itself.

my $callback = K('method_name', $self, $arg1, $arg2, ...);

param

Extracts a parameter from an argument hash.

sub thing{
  my ($self, %param) = @_;
  my $foo = param 'foo', %param, 'default'; # equivalent: $param{foo} // 'default';
  my $bar = param 'bar', %param;            # equivalent: $param{bar} // croak "expected parameter 'bar'";
}

interval

Returns a code ref that, when called, returns an increasing interval value to simplify performing a task using a logarithmic backoff. When the code ref is called with an argument (a truthy one), the backoff will reset back to the original argument.

my $intvl = interval 5;

until (some_task_succeeds()) {
  sleep $intvl->();
}

AUTHOR

Jeff Ober <sysread@fastmail.fm>

COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by Jeff Ober.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.