The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Data::AnyXfer::Elastic::Import::Storage - Import storage role

SYNOPSIS

    package My::Type::Of::Storage;

    use Moo;
    use MooX::Types::MooseLike::Base qw(:all);


    with 'Data::AnyXfer::Elastic::Import::Storage';


    # implement interface

    1;

DESCRIPTION

This role represents a Data::AnyXfer::Elastic storage backend for import data.

The interface allows the storage and retrieval of data, persistence, and provides some helper methods.

ATTRIBUTES

METHODS REQUIRED

get_destination_info

    my $info = $storage->get_destination_info;

Returns the target information for the save operation. This is relative to the type of storage backend. This could be database information, or a file system location etc. Consult your storage implementation.

list_items

    my @item_names = $storage->list_items;

Returns a list of all item names. Takes no arguments.

add_item

    unless ( $storage->add_item('test_item', $content) ) {

        croak 'Failed to add test_item';

    }

Adds a new item to the storage backend. Fails if this item already exists. Returns a boolean indicating success or failure.

set_item

    $storage->set_item('test_item', $content);

Stores content under the specified item name in the storage backend. Clobbers any existing values.

Should always return 1.

remove_item

    $storage->remove_item('test_item');

Deletes the specified item from the storage backend.

get_item

    my $content = $storage->get('test_item');

Retrieves the contents of an item from the storage backend.

reload

    $storage->reload;

Reinitialise the storage backend. Pickup any external changes in the storage for backends where this is relevant.

Does not have to return anything.

May be implemented as a noop.

save

    $storage->save;

Persist any changes to storage, beyond the life of this instance, when relevant.

Should die on failure.

cleanup

    $storage->cleanup;

Cleans up any working copy, or partial and temporary files that may have been created or in use by this instance.

METHODS PROVIDED

add

    $storage->add(
        item_1 => 'Hello',
        item_2 => 'World!',
    );

Convenience method. Allows multiple items to be added. Already existing items will silently fail.

Use "add_item" directly if you wish to detect and handle this.

Always returns 1;

set

    $storage->set(
        item_1 => 'Hello',
        item_2 => 'World!',
    );

Convenience method. Allows multiple items to be set. Already existing items will be clobbered.

Always returns 1;

COPYRIGHT

This software is copyright (c) 2019, Anthony Lucas.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.