Why not adopt me?
NAME
Data::EventStream - Perl extension for event processing
VERSION
This document describes Data::EventStream version 0.13
SYNOPSIS
use Data::EventStream;
$es = Data::EventStream->new;
$es->add_aggregator( $agg, %params );
while ( my $event = get_event() ) {
$es->add_event($event);
}
DESCRIPTION
Module provides methods to analyze stream of events.
Please check Project Homepage for more information about using this module and examples.
METHODS
$class->new(%params)
Creates a new instance. The following parameters are accepted:
- time
-
Initial model time, by default 0
- time_sub
-
Reference to a subroutine that returns time associated with the event passed to it as the only parameter. This argument is not required if you are only going to use count based sliding windows.
- filter
-
Reference to a subroutine that is invoked every time new event is being added. The new event is passed as the only argument to this subroutine. If subroutine returns false event is ignored.
$self->set_filter(\&sub)
Set a new filter
$self->remove_filter
Remove filter
$self->set_time($time)
Set new model time. This time must not be less than the current model time.
$self->next_leave
Return time of the next nearest leave or reset event
$self->add_aggregator($aggregator, %params)
Add a new aggregator object. An aggregator that is passed as the first argument should implement interface described in Data::EventStream::Aggregator documentation. Parameters that go next can be the following::
- count
-
Maximum number of event for which aggregator can aggregate data. When number of aggregated events reaches this limit, each time before a new event enters aggregator, the oldest aggregated event will leave it.
- duration
-
Maximum period of time handled by aggregator. Each time the model time is updated, events with age exceeding specified duration are leaving aggregator.
- batch
-
If enabled, when count or duration limit is reached, aggregator is reset and all events leaving it at once.
- start_time
-
Time when the first period should start. Used in conjunction with duration and batch. By default current model time.
- disposable
-
Used in conjunction with batch. Aggregator only aggregates specified period once and on reset it is removed from the list of aggregators.
- on_enter
-
Callback that should be invoked after event entered aggregator. Aggregator object is passed as the only argument to callback.
- on_leave
-
Callback that should be invoked before event leaves aggregator. Aggregator object is passed as the only argument to callback.
- on_reset
-
Callback that should be invoked before resetting the aggregator. Aggregator object is passed as the only argument to callback.
$self->add_event($event)
Add new event
SEE ALSO
Project homepage at http://trinitum.github.io/perl-Data-EventStream/
BUGS
Please report any bugs or feature requests via GitHub bug tracker at http://github.com/trinitum/perl-Data-EventStream/issues.
AUTHOR
Pavel Shaydo <zwon at cpan.org>
LICENSE AND COPYRIGHT
Copyright (C) 2014 Pavel Shaydo
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.