The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Juno::Role::Check - Check role for Juno

VERSION

version 0.010

DESCRIPTION

This role provides Juno checks with basic functionality they all share. This document is intended for anyone writing (or planning on writing) a check for Juno.

The purpose of this role is to both enforce behavior of Juno checks and provide various helpful attributes and methods for any check.

CONSTRAINTS

The role requires the consumer object implements a check method.

ATTRIBUTES

hosts

An arrayref consisting a list of hosts (with no enforcement other than a string) that can then be checked. Each check has multiple hosts so they are check more than a single target in each object instance. This can be an IP address or a hostname of any type. Different types can be mixed freely.

This attribute is being propagated from the main Juno object.

Default: empty array.

interval

A number (including fractions) indicating the interval of your check. This role runs your check (using the check method you provide) in this interval, so you shouldn't worry or care about it. You can, however, specify a different default interval, if you want.

Default: 10 seconds.

after

A number (including fractions) indicating the delay before the checking cycle begins. This only applies for the first check. From that point on, the cycles will be scheduled every interval indicated by the interval attribute.

Default: 0 seconds. This means it should start right away.

on_before

A callback to run before an action occurs. Your check needs to call it before you actually call whatever check you're running. This gives the user an opportunity to time the check itself or to log it, for instance.

You can check whether you got such a callback using the predicate has_on_before described below.

on_result

A callback to run as soon as an action returns some response. You need to provide the user with this to let them control it all if that's what they want. Perhaps they don't want to count on your decision of what is good or not, or perhaps they have different values for good or bad.

You can check whether you got such a callback using the predicate has_on_result described below.

on_success

A callback to run when you decide a check has been successful. For example, Juno::Check::HTTP calls this callback if the response code has 2xx.

You can check whether you got such a callback using the predicate has_on_success described below.

on_fail

A callback to run when you decide a check has failed. This is the opposite of the above. For example, Juno::Check::HTTP calls this callback if the response code is anything but 2xx.

You can check whether you got such a callback using the predicate has_on_fail described below.

watcher

A watcher attribute that holds the timer that runs your check. You can change this watcher using the set_watcher method below or reset the watcher (thus ending your check, even if Juno is still running) using the reset_watcher method below.

METHODS

has_on_before

This is a predicate method to check whether the user has give you an on_before callback.

has_on_result

This is a predicate method to check whether the user has give you an on_result callback.

has_on_success

This is a predicate method to check whether the user has give you an on_success callback.

has_on_fail

This is a predicate method to check whether the user has give you an on_fail callback.

run

This method is called by Juno (but can be called separately if that's what you want to do) in order to schedule and run your check.

This sets the timer (under the watcher attribute described above) for your check.

set_watcher

This method can override the existing watcher. It's hard to think of a usage for it, but there it is anyway.

clear_watcher

This method clears the watcher completely, thus stopping your check. It will not stop any existing code, but will make sure no more cycles of your check will run. It also doesn't stop Juno from running, or other checks from running for that matter. It will only stop yours, while lettings everything continue running.

This can mostly be useful for the user.

AUTHORS

  • Sawyer X <xsawyerx@cpan.org>

  • Adam Balali <adamba@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Sawyer X.

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