Permalink
Browse files

fix call back in _archive_index

  • Loading branch information...
1 parent 5db49e6 commit ce0ae91cde532cfa0cf49a1789f49486214528c3 @biro biro committed with bobtfish Jan 8, 2013
Showing with 7 additions and 5 deletions.
  1. +7 −5 lib/Message/Passing/Output/ElasticSearch.pm
View
12 lib/Message/Passing/Output/ElasticSearch.pm
@@ -205,23 +205,25 @@ has _archive_timer => (
},
);
+# _archive_index run 1 time per day to close index older than 7 days and delete
+# index older than 30 days
+#
sub _archive_index {
my ($self) = @_;
my $dt = DT->from_epoch(epoch => time());
my $dt_to_close = $dt->clone->subtract(days => 7);
my $index_to_close = $self->_index_name_by_dt($dt_to_close);
- my $result = $self->_es->close_index(index => $index_to_close);
- warn "Close index: $index_to_close" . Dumper($result) . "\n";
+ $self->_es->close_index(index => $index_to_close)
+ ->cb( sub { warn "Close index: $index_to_close \n" if $self->verbose; });
my $dt_to_delete = $dt->clone->subtract(days => 30);
my $index_to_delete = $self->_index_name_by_dt($dt_to_delete);
- $result = $self->_es->delete_index(
+ $self->_es->delete_index(
index => $index_to_delete,
ignore_missing => 1,
- );
- warn "Delete index: $index_to_delete" . Dumper($result) . "\n";
+ )->cb( sub { warn "Delete index: $index_to_delete \n" if $self->verbose;});
}

0 comments on commit ce0ae91

Please sign in to comment.