Why not adopt me?
NAME
Data::EventStream - Perl extension for event processing
VERSION
This document describes Data::EventStream version 0.03
SYNOPSIS
use Data::EventStream;
DESCRIPTION
WARNING: this distribution is in the phase of active development, all interfaces are likely to change in next versions.
Module provides methods to analyze stream of events.
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.
$self->set_time($time)
Set new model time. This time must not be less than the current model time.
$self->add_aggregator($aggregator, type => (count|time), %params)
Add a new aggregator object. Depending on type, various parameters can be specified.
Options common for all 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.
Events number based aggregators
If aggregator has type count, then it aggregates data for particular number of events and the following parameters are accepted:
- length
-
Aggregate data for the specified number of events. If aggregator already aggregates data for that many events, then one event should leave aggregator before another one can enter it. This parameter is required.
- shift
-
Aggregate data with delay. Event enters aggregator only after specified by shift number of events were added to the stream. By default 0.
- batch
-
As soon as number of events specified by length parameter is reached, aggregator is reset and all events leave it at once. By default not set.
Time based aggregators
If aggregator has type time, then it aggregates data for the specified period of time and the following parameters are accepted:
- period
-
Aggregate data for the specified period of time. Each time set_time is called, events that are older then the specified period are leaving aggregator. This option is required.
$self->add_event($event)
Add new event
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.