Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/robrwo/moosex-failover
Instantiate Moose classes with failover
https://github.com/robrwo/moosex-failover
Last synced: 11 days ago
JSON representation
Instantiate Moose classes with failover
- Host: GitHub
- URL: https://github.com/robrwo/moosex-failover
- Owner: robrwo
- Created: 2014-11-14T14:16:11.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2014-12-18T08:58:17.000Z (almost 10 years ago)
- Last Synced: 2024-10-11T21:56:34.374Z (about 1 month ago)
- Language: Perl
- Size: 469 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.pod
- Changelog: Changes
Awesome Lists containing this project
README
=head1 NAME
MooseX::Failover - Instantiate Moose classes with failover
=head1 VERSION
v0.2.0_01
=head1 SYNOPSIS
# In your class:
package MyClass;
use Moose;
with 'MooseX::Failover';# When using the class
my $obj = MyClass->new( %args, failover_to => 'OtherClass' );
# If %args contains missing or invalid values or new otherwise
# fails, then $obj will be of type "OtherClass".=head1 INSTALLATION
See
L.=head2 Required Modules
This distribution requires Perl v5.10.0.
This distribution requires the following modules:
=over 4
=item * L (version 0.20)
=item * L (version 2.1101)
=item * L
=item * L
=back
This distribution recommends the following modules:
=over 4
=item * L
=back
=head1 RECENT CHANGES
=head2 Documentation
=over 4
=item *
Added note about making classes immutable.
=back
=head2 Enhancements
=over 4
=item *
Minor optimizations.
=item *
Uses namespace::autoclean.
=back
See the F file for a longer revision history.
=head1 DESCRIPTION
This role provides constructor failover for L classes.
If a class cannot be instantiated because of invalid arguments
(perhaps from an untrusted source), then instead it returns the
failover class (passing the same arguments to that class).This allows for cleaner design, by not forcing you to duplicate type
checking for class parameters.Note that this is roughly equivalent to using
my $obj = eval { MyClass->new(%args) //
OtherClass->new( %args, error => $@ );Note that your failover class should support the same methods as the
original class. A use case for this role would be for instantiating
L objects, where the failover is a
Web::Machine::Resource object that returns an error page.Ideally, your failover class would satisy the Liskov Substitution
Principle, so that (roughly) all provable properties of the original
class are also provable of the failover class. In practice, we only
care about the properties (methods and attributes) that are actually
used in our programs.=head1 AUTHOR
Robert Rothenberg C<>
=head1 Acknowledgements
=over
=item Thermeon Europe.
=item Piers Cawley.
=back
=head1 COPYRIGHT
Copyright 2014 Thermeon Europe.
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.This program is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose.