Amazon-SQS-Client

 view release on metacpan or  search on metacpan

bin/QueueDaemon.pl  view on Meta::CPAN

sub init_logger {
########################################################################
  my ($options) = @_;

  my ( $logfile, $loglevel ) = @{$options}{qw(logfile loglevel)};

  $loglevel //= 'info';

  $loglevel = {
    error => $ERROR,
    debug => $DEBUG,
    trace => $TRACE,
    info  => $INFO,
    warn  => $WARN,
  }->{ lc $loglevel };

  $loglevel //= $INFO;

  $logfile //= 'stderr';

  my $log4perl_config;

bin/QueueDaemon.pl  view on Meta::CPAN


 -h, --help               help
 -c, --config             config file name
 -C, --create-queue       create the queue if it does not exist
 -d, --daemonize          daemonize the script (default)
     --no-daemonize       
 -D, --delete-when        never, always, error
 -E, --exit-when          never, always, error, false
 -e, --endpoint-url       default: https://sqs.amazonaws.com
 -L, --logfile            name of logfile
 -l, --loglevel           log level (trace, debug, info, warn, error)
 -H, --handler            name of the handler class, default: Amazon::SQS::QueueHandler
 -m, --max-children       not implemented (default: 1)
 -s, --max-sleep-time     default: 5 seconds
     --max-messages       fixed at 1 currently
 -M, --message-type       mime type of messages (text/plain, application/json, 
                          application/x-www-form-encoded), default: text/plain
 -q, --queue              queue name (not url)
     --queue-interval     amount of time to sleep
 -p, --pidfile            fully qualified path of pid file, default: /var/run/QueueDaemon.pl.in
 -v, --visibility-timeout visibility timeout in seconds, default: 30

bin/create-queue.pl  view on Meta::CPAN

  return 0;
}

########################################################################
sub init_client {
########################################################################
  my ($options) = @_;

  my $client_options = {
    ServiceURL => $options->{'endpoint-url'},
    $options->{debug} ? ( loglevel => 'debug' ) : ( loglevel => 'info' ),
  };

  my @credentials = ( $ENV{AWS_ACCESS_KEY_ID}, $ENV{AWS_SECRET_ACCESS_KEY} );

  return Amazon::SQS::Client->new( @credentials, $client_options );
}

########################################################################
sub main {
########################################################################
  my @option_specs = qw(
    debug|d
    dlq!
    delay-seconds|D=i
    endpoint-url|e=s
    help|h
    max-receive-count|c=i
    maximum-message-size|S=i
    message-retention-period|p=i
    queue|q=s
    receive-message-wait-time-seconds|w=i
    visibility-timeout|v=i

lib/Amazon/SQS/Config.pm  view on Meta::CPAN

=back 

=head2 log

The log section describe how the F<QueueDaemon.pl> script will log
messages. The script instantiates a L<Log::Log4perl> logger
automatically for you that will log to the parent's STDERR. See note
below regarding how the daemonization process closes STDOUT, STDERR.

  [log]
  level = debug
  file = /tmp/amazon_sqs.log

When you daemonize the script, if either C<stdout> or C<stderr> is set
the parent's STDOUT or STDERR will be closed and then reopened using
those settings. If these are not set, then they will not be
closed. The closing STDERR will stop the C<Log::Log4perl> logger.

=over 5

=item level

C<Log::Log4perl> logging level ('trace', 'debug', 'info', 'warn', 'error').

=item file

Name of a log file for C<Log::Log4perl> messages. You can also use the
values of 'stdout' or 'stderr' to log to STDOUT and STDERR.

=back

I<WARNING: You should probably make sure that the F<.ini> file is properly
protected with restrictive permissions if you place credentials in

share/example.pl  view on Meta::CPAN


########################################################################
sub main {
########################################################################
  my %options;

  my @option_specs = qw(
    file|f=s
    help|h
    endpoint-url|e=s
    debug|d
  );

  my $retval = GetOptions( \%options, @option_specs );

  if ( !$retval || ( $options{help} && !@ARGV ) ) {
    pod2usage(1);
  }

  my $example = shift @ARGV;

share/example.pl  view on Meta::CPAN


  if ( $options{help} ) {
    $sample->help();
  }

  eval { $sample->sample(@ARGV); };

  $sample->check_error($EVAL_ERROR);

  return 0
    if !$options{debug};

  print {*STDERR} Dumper(
    [ request     => $sample->get_service->get_last_request,
      response    => $sample->get_service->get_last_response,
      credentials => $sample->get_service->get_credentials,
    ]
  );

  return 0;
}



( run in 0.532 second using v1.01-cache-2.11-cpan-49f99fa48dc )