Skip to content

Commit

Permalink
extending documentation on MetaCPAN::Script::Mapping methods
Browse files Browse the repository at this point in the history
  • Loading branch information
bodo-hugo-barwich committed Nov 6, 2021
1 parent 8c873f8 commit 55883c1
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/MetaCPAN/Role/Script.pm
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ sub check_health {
my $sinfo_rs
= $self->es->cat->indices( h => [ 'index', 'health' ] );

%{ $self->indices_info } = ();
$self->indices_info({});

while ( $sinfo_rs =~ /^([^[:space:]]+) +([^[:space:]]+)/gm ) {
$self->indices_info->{$1}
Expand All @@ -289,7 +289,7 @@ sub check_health {
my $sinfo_rs
= $self->es->cat->aliases( h => [ 'alias', 'index' ] );

%{ $self->aliases_info } = ();
$self->aliases_info({});

while ( $sinfo_rs =~ /^([^[:space:]]+) +([^[:space:]]+)/gm ) {
$self->aliases_info->{$1}
Expand Down Expand Up @@ -324,7 +324,7 @@ sub await {
. " : ready"
};

%{ $self->cluster_info } = ( %{ $es->info } );
$self->cluster_info( \%{ $es->info } );
}
};

Expand Down
109 changes: 109 additions & 0 deletions lib/MetaCPAN/Script/Mapping.pm
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,12 @@ __PACKAGE__->meta->make_immutable;

__END__
=pod
=head1 NAME
MetaCPAN::Script::Mapping - Script to set the index and mapping the types
=head1 SYNOPSIS
# bin/metacpan mapping --show_cluster_info # show basic info about the cluster, indices and aliases
Expand All @@ -615,3 +621,106 @@ __END__
This is the index mapping handling script.
Used rarely, but carries the most important task of setting
the index and mapping the types.
=head1 OPTIONS
This Script accepts the following options
=over 4
=item Option C<--show_cluster_info>
This option makes the Script show basic information about the I<ElasticSearch> Cluster
and its indices and aliases.
This information has to be collected with the C<MetaCPAN::Role::Script::check_health()> Method.
On Script start-up it is empty.
bin/metacpan mapping --show_cluster_info
See L<Method C<MetaCPAN::Role::Script::check_health()>>
=item Option C<--delete>
This option makes the Script delete all indices configured in the project and re-create them emtpy.
It verifies the index integrity of the indices and aliases calling the methods
C<MetaCPAN::Role::Script::check_health()> and C<verify_mapping()>.
If the C<verify_mapping()> Method fails it exits the Script
with B<Exit Code> C< 1 >.
bin/metacpan mapping --delete
See L<Method C<deploy_mapping()>>
See L<Method C<verify_mapping()>>
See L<Method C<MetaCPAN::Role::Script::check_health()>>
=item Option C<--all>
This option is only effective in combination with Option C<--delete>.
It uses the information gathered by C<MetaCPAN::Role::Script::check_health()> to delete
B<ALL> indices in the I<ElasticSearch> Cluster.
This option is usefull to reconstruct a broken I<ElasticSearch> Cluster
bin/metacpan mapping --delete --all
See L<Option C<--delete>>
See L<Method C<deploy_mapping()>>
See L<Method C<MetaCPAN::Role::Script::check_health()>>
=back
=head1 METHODS
This Package provides the following methods
=over 4
=item C<deploy_mapping()>
Deletes and re-creates the indices and aliases defined in the Project.
The user will be requested for manual confirmation on the command line before the elemination.
The integrity of the indices and aliases will be checked with the C<verify_mapping()> Method.
On successful creation it returns C< 1 >, otherwise it returns C< 0 >.
B<Returns:> It returns C< 1 > when the indices and aliases are created and verified as correct.
Otherwise it returns C< 0 >.
B<Exceptions:> It can throw exceptions when the connection to I<ElasticSearch> fails
or there is any issue in any I<ElasticSearch> Request run by the Script.
See L<Option C<--delete>>
See L<Method C<verify_mapping()>>
See L<Method C<MetaCPAN::Role::Script::check_health()>>
=item C<verify_mapping( \%indices, \%aliases )>
Checks the defined indices and aliases against the actually in the I<ElasticSearch> Cluster
existing indices and aliases which must have been requested with
the C<MetaCPAN::Role::Script::check_health()> Method.
B<Parameters:>
C<\%indices> - Reference to a hash that defines the indices required for the Project.
C<\%aliases> - Reference to a hash that defines the aliases required for the Project.
B<Returns:> It returns C< 1 > when the indices and aliases are created and verified as correct.
Otherwise it returns C< 0 >.
B<Exceptions:> It can throw exceptions when the connection to I<ElasticSearch> fails
or there is any issue in any I<ElasticSearch> Request run by the Script.
See L<Option C<--delete>>
See L<Method C<verify_mapping()>>
See L<Method C<MetaCPAN::Role::Script::check_health()>>
=back
=cut

0 comments on commit 55883c1

Please sign in to comment.