App-ElasticSearch-Utilities
view release on metacpan or search on metacpan
"Test::Pod::Coverage" : "1.08"
}
},
"runtime" : {
"requires" : {
"CHI" : "0",
"CLI::Helpers" : "0",
"Carp" : "0",
"Clone" : "0",
"Const::Fast" : "0",
"DateTime" : "0",
"File::Basename" : "0",
"File::Slurp::Tiny" : "0",
"Getopt::Long" : "0",
"Getopt::Long::Descriptive" : "0",
"HTTP::Request" : "0",
"Hash::Flatten" : "0",
"Hash::Merge::Simple" : "0",
"IO::Socket::INET" : "0",
"IPC::Run3" : "0",
"JSON::MaybeXS" : "0",
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: App-ElasticSearch-Utilities
requires:
CHI: '0'
CLI::Helpers: '0'
Carp: '0'
Clone: '0'
Const::Fast: '0'
DateTime: '0'
File::Basename: '0'
File::Slurp::Tiny: '0'
Getopt::Long: '0'
Getopt::Long::Descriptive: '0'
HTTP::Request: '0'
Hash::Flatten: '0'
Hash::Merge::Simple: '0'
IO::Socket::INET: '0'
IPC::Run3: '0'
JSON::MaybeXS: '0'
Makefile.PL view on Meta::CPAN
],
"LICENSE" => "bsd",
"MIN_PERL_VERSION" => "5.016000",
"NAME" => "App::ElasticSearch::Utilities",
"PREREQ_PM" => {
"CHI" => 0,
"CLI::Helpers" => 0,
"Carp" => 0,
"Clone" => 0,
"Const::Fast" => 0,
"DateTime" => 0,
"File::Basename" => 0,
"File::Slurp::Tiny" => 0,
"Getopt::Long" => 0,
"Getopt::Long::Descriptive" => 0,
"HTTP::Request" => 0,
"Hash::Flatten" => 0,
"Hash::Merge::Simple" => 0,
"IO::Socket::INET" => 0,
"IPC::Run3" => 0,
"JSON::MaybeXS" => 0,
Makefile.PL view on Meta::CPAN
);
my %FallbackPrereqs = (
"CHI" => 0,
"CLI::Helpers" => 0,
"Carp" => 0,
"Clone" => 0,
"Const::Fast" => 0,
"Data::Dumper" => 0,
"DateTime" => 0,
"File::Basename" => 0,
"File::Slurp::Tiny" => 0,
"File::Spec" => 0,
"File::Temp" => 0,
"Getopt::Long" => 0,
"Getopt::Long::Descriptive" => 0,
"HTTP::Request" => 0,
"Hash::Flatten" => 0,
"Hash::Merge::Simple" => 0,
"IO::Handle" => 0,
# This file is generated by Dist::Zilla::Plugin::CPANFile v6.030
# Do not edit this file directly. To change prereqs, edit the `dist.ini` file.
requires "CHI" => "0";
requires "CLI::Helpers" => "0";
requires "Carp" => "0";
requires "Clone" => "0";
requires "Const::Fast" => "0";
requires "DateTime" => "0";
requires "File::Basename" => "0";
requires "File::Slurp::Tiny" => "0";
requires "Getopt::Long" => "0";
requires "Getopt::Long::Descriptive" => "0";
requires "HTTP::Request" => "0";
requires "Hash::Flatten" => "0";
requires "Hash::Merge::Simple" => "0";
requires "IO::Socket::INET" => "0";
requires "IPC::Run3" => "0";
requires "JSON::MaybeXS" => "0";
scripts/es-alias-manager.pl view on Meta::CPAN
#!perl
# PODNAME: es-alias-manager.pl
# ABSTRACT: Allow easy alias management for daily indexes
use strict;
use warnings;
use App::ElasticSearch::Utilities qw(:default);
use CLI::Helpers qw(:all);
use DateTime;
use Getopt::Long qw(:config no_ignore_case no_ignore_case_always);
use Pod::Usage;
use Ref::Util qw( is_ref );
use YAML::XS ();
#------------------------------------------------------------------------#
# Argument Collection
my %opt;
GetOptions(\%opt,
'all',
scripts/es-alias-manager.pl view on Meta::CPAN
}
my $ALIAS = YAML::XS::LoadFile( $CFG{config} ) or die "unable to read $CFG{config}";
# Create the target uri for the ES Cluster
my $TARGET = exists $opt{host} && defined $opt{host} ? $opt{host} : 'localhost';
# Grab a connection to ElasticSearch
my $es = es_connect();
# Delete Indexes older than a certain point
my $TODAY = DateTime->now()->truncate( to => 'day' );
my $indices = es_request('_aliases');
if ( !defined $indices ) {
output({color=>"red"}, "Unable to locate indices by get_aliases()!");
exit 1;
}
debug_var($indices);
my %PARTS = (
DATE => {
scripts/es-alias-manager.pl view on Meta::CPAN
# Setup Formatting
if (exists $ALIAS->{$base}{daily}) {
$ALIAS->{$base}{daily} =~ s/\{\{([^\}]+)\}\}/$PARTS{$1}->{FMT}/g;
}
if (exists $ALIAS->{$base}{relative}) {
$ALIAS->{$base}{relative}{alias} =~ s/\{\{([^\}]+)\}\}/$PARTS{$1}->{FMT}/g;
while( my ($period,$def) = each %{ $ALIAS->{$base}{relative}{periods} }) {
my %dt = (
to => $TODAY->clone(),
from => exists $def->{from} ? $TODAY->clone() : DateTime->from_epoch(epoch => 0)->truncate( to => 'day'),
);
debug("Period[$period] subtracting: ");
debug_var($def);
foreach my $d (keys %dt) {
if ( exists $def->{$d} ) {
$dt{$d}->subtract( %{ $def->{$d}} );
debug("$period $d " . $dt{$d}->ymd);
}
}
$ALIAS->{$base}{relative}{periods}{$period} = \%dt;
scripts/es-alias-manager.pl view on Meta::CPAN
my %current = map { $_ => 1 }
grep { !/^\./ }
grep { not exists $IGNORE{$_} }
keys %{ $indices->{$index}{aliases} };
my $managed = 0;
my %desired = ();
while( my($name,$map) = each %{ $ALIAS }) {
if ($index =~ /$map->{re}/) {
$managed++;
my $idx_dt = DateTime->new( map { $_ => $+{$_} } qw(year month day) );
verbose("$index is a $name index.");
if ( exists $map->{daily} ) {
my $daily = $idx_dt->strftime($map->{daily});
$desired{$daily} = 1;
}
if ( exists $map->{relative} ) {
while (my ($period,$def) = each %{ $map->{relative}{periods} }) {
debug(sprintf("Checking index date (%s) is between %s and %s",
$idx_dt->ymd,
t/02-index-data.t view on Meta::CPAN
#!perl
#
use strict;
use warnings;
use App::ElasticSearch::Utilities qw(es_index_bases es_index_days_old es_index_strip_date);
use CLI::Helpers qw(:output);
use DateTime;
use Data::Dumper;
use POSIX qw(strftime);
use Test::More;
$Data::Dumper::Indent = 1;
$Data::Dumper::Sortkeys = 1;
my $now = DateTime->now();
my @days_old = qw(0 1 3 5 8 13 21 90);
my %TESTS=(
'notadate-100000' => {
es_index_bases => 'notadate',
es_index_days_old => undef,
es_index_strip_date => 'notadate-100000',
},
strftime('mystery-science-theater-3000-%Y.%m.%d', gmtime) => {
es_index_bases => 'mystery,mystery-science,mystery-science-theater',
( run in 0.247 second using v1.01-cache-2.11-cpan-05444aca049 )