NAME
Net::Stomp::MooseHelpers::ReadTrace - class to read the output of Net::Stomp::MooseHelpers::TraceStomp
VERSION
version 3.0
SYNOPSIS
my $reader = Net::Stomp::MooseHelpers::ReadTrace->new({
trace_basedir => '/tmp/mq',
});
my @frames = $reader->sorted_frames('/queue/somewhere');
DESCRIPTION
Net::Stomp::MooseHelpers::TraceStomp and Net::Stomp::MooseHelpers::TraceOnly write STOMP frames to disk. This class helps you read them back.
ATTRIBUTES
trace_basedir
The directory from which frames will be read. Accepts strings and Path::Class::Dir objects.
METHODS
read_frame_from_filename
my $stomp_frame = $reader->read_frame_from_filename('/a/path');
Given a filename (unrelated to "trace_basedir"), returns a Net::Stomp::Frame object parsed from it, using "read_frame_from_fh".
read_frame_from_fh
my $stomp_frame = $reader->read_frame_from_fh($fh);
Given a filehandle (binmode
it first!), returns a Net::Stomp::Frame object parsed from it. If the filehandle contains more than one frame, reads the first one and leaves the read position just after it.
If the file was not a dumped STOMP frame, this function will probably return nothing; if it looked enough like a STOMP frame, you'll get back whatever could be parsed.
trace_subdir_for_destination
my $dir = $reader->trace_subdir_for_destination($destination);
Returns a Path::Class::Dir object pointing at the (possibly non-existent) directory used to store frames for the given destination.
->trace_subdir_for_destination()
is the same as ->trace_basedir
.
Passing an explicit undef
or an empty string will throw an exception, see "sorted_filenames" and "clear_destination" for the reason.
sorted_filenames
my @names = $reader->sorted_filenames();
my @names = $reader->sorted_filenames($destination);
Given a destination (/queue/something
or similar), returns all frame dump filenames found under the corresponding dump directory under "trace_basedir", sorted by filename (that is, by timestamp).
If you don't specify a destination, all filenames from all destinations will be returned. Passing an explicit undef
or an empty string will throw an exception, to save you when you try doing things like:
my $dest = get_something_from_config;
my @names = $reader->sorted_filenames($dest);
and end up getting way more items than you thought.
clear_destination
$reader->clear_destination();
$reader->clear_destination($destination);
Given a destination (/queue/something
or similar), removes all stored frames for it.
If you don't specify a destination, all frames for all destinations will be removed. Passing an explicit undef
or an empty string will throw an exception, to save you when you try doing things like:
my $dest = get_something_from_config;
$reader->clear_destination($dest);
and end up deleting way more than you thought.
sorted_frames
my @frames = $reader->sorted_frames();
my @frames = $reader->sorted_frames($destination);
Same as "sorted_filenames", but returns the parsed frames instead of the filenames.
AUTHOR
Gianni Ceccarelli <gianni.ceccarelli@net-a-porter.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Net-a-porter.com.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.