Beam-Minion
view release on metacpan or search on metacpan
lib/Beam/Minion/Util.pm view on Meta::CPAN
package Beam::Minion::Util;
our $VERSION = '0.019';
# ABSTRACT: Utility functions for Beam::Minion
#pod =head1 SYNOPSIS
#pod
#pod use Beam::Minion::Util qw( minion );
#pod
#pod my $minion = minion();
#pod my %attrs = minion_attrs();
#pod
#pod =head1 DESCRIPTION
#pod
#pod This module contains helper routines for L<Beam::Minion>.
#pod
#pod =head1 SEE ALSO
#pod
#pod L<Beam::Minion>
#pod
#pod =cut
use Mojo::Base -strict, -signatures;
use Exporter qw( import );
use Minion;
use Beam::Runner::Util qw( find_containers );
use Scalar::Util qw( weaken );
use Mojolicious;
use Mojo::Log;
use Beam::Wire;
use YAML::PP qw( LoadFile );
use Log::Any qw($LOG);
our @EXPORT_OK = qw( minion_init_args minion build_mojo_app );
our %BACKEND = (
sqlite => 'SQLite',
postgres => 'Pg',
mongodb => 'MongoDB',
mysql => 'mysql',
);
# The saved init args, in case we override them with Beam::Minion->init
our @INIT_ARGS = ();
#pod =sub minion_init_args
#pod
#pod my %args = minion_init_args();
#pod
#pod Get the arguments needed to initialize a new Minion instance by parsing
#pod the C<BEAM_MINION> environment variable.
#pod
#pod This environment variable can take a few forms:
#pod
#pod =over
#pod
#pod =item file://<path>
#pod
#pod A path to a YAML file of configuration to read. Should contain a single key and value
#pod which are the Minion backend to use and the argument to its constructor.
#pod
#pod =item <url>
#pod
#pod A simple backend URL like C<postgres://postgres@/test>,
#pod C<sqlite:/tmp/minion.db>, C<mongodb://127.0.0.1:27017>, or
#pod C<mysql://user@127.0.0.1/minion>. The following backends are supported:
#pod L<Minion::Backend::SQLite>, L<Minion::Backend::Pg>,
#pod L<Minion::Backend::MongoDB>, L<Minion::Backend::mysql>.
#pod
#pod =item <backend>+<url>
#pod
#pod A backend name and arguments, separated by C<+>, like
#pod C<Storable+/tmp/minion.db>. Any backend may be used this way.
#pod
#pod If your backend requires more arguments, you can separate them with
#pod C<+>:
#pod
#pod # Configure the MySQL backend with a DBI DSN
#pod BEAM_MINION=mysql+dsn+dbi:mysql:minion
#pod
#pod =back
#pod
#pod =cut
sub minion_init_args {
if (@_) {
@INIT_ARGS = @_;
( run in 1.053 second using v1.01-cache-2.11-cpan-600a1bdf6e4 )