GitXplorerGitXplorer
d

io-storm

public
11 stars
2 forks
0 issues

Commits

List of commits on branch master.
Unverified
6a5295ed155de23baf6d4d7ec06310870a3d6482

Update version to 0.17

ddan-blanchard committed 10 years ago
Unverified
85a2fd274cda58c8d45a7e2c1424d0e22d1d8a75

Fix == instead of eq in Bolt.pm

ddan-blanchard committed 10 years ago
Unverified
53f1fe26a481b76c363d254dad60facfc5398aa6

Update version in README

ddan-blanchard committed 10 years ago
Unverified
d1bac6bcac9fa2f8c6eee5ce3eae7f98eb45930e

Fix #1 and add support for multilang heartbeats

ddan-blanchard committed 10 years ago
Unverified
6c58d4674f7a92e472a0b1a61f5615ebd06c5dd9

Bump version to 0.15

ddan-blanchard committed 10 years ago
Unverified
8fd8fd0e6e28d587ac679f48d52a4e1604065978

Switch to binmode from open pragma. Should fix UTF-8 issues.

ddan-blanchard committed 10 years ago

README

The README file for this repository.

NAME

IO::Storm - IO::Storm allows you to write Bolts and Spouts for Storm in Perl.

VERSION

version 0.17

SYNOPSIS

package SplitSentenceBolt;

use Moo;
use namespace::clean;

extends 'Storm::Bolt';

sub process {
    my ($self, $tuple) = @_;

    my @words = split(' ', $tuple->values->[0]);
    foreach my $word (@words) {

        $self->emit([ $word ]);
    }

}

SplitSentenceBolt->new->run;

DESCRIPTION

IO::Storm allows you to leverage Storm's multilang support to write Bolts and Spouts in Perl. As of version 0.02, the API is designed to very closely mirror that of the Streamparse Python library. The exception being that we don't currently support the BatchingBolt class or the emit_many methods.

Bolts

To create a Bolt, you want to extend the Storm::Bolt class.

package SplitSentenceBolt;

use Moo;
use namespace::clean;

extends 'Storm::Bolt';

Processing tuples

To have your Bolt start processing tuples, you want to override the process method, which takes a IO::Storm::Tuple as its only argument. This method should do any processing you want to perform on the tuple and then emit its output.

sub process {
    my ($self, $tuple) = @_;

    my @words = split(' ', $tuple->values->[0]);
    foreach my $word (@words) {

        $self->emit([ $word ]);
    }

}

To actually start your Bolt, call the run method, which will initialize the bolt and start the event loop.

SplitSentenceBolt->new->run;

Automatic reliability

By default, the Bolt will automatically handle acks, anchoring, and failures. If you would like to customize the behavior of any of these things, you will need to set the auto_anchor, auto_anchor, or auto_fail attributes to 0. For more information about Storm's guaranteed message processing, please see their documentation.

Spouts

To create a Spout, you want to extend the Storm::Spout class.

package SentenceSpout;

use Moo;
use namespace::clean;

extends 'Storm::Spout';

Emitting tuples

To actually emit anything on your Spout, you have to implement the next_tuple method.

my $sentences = ["a little brown dog",
                 "the man petted the dog",
                 "four score and seven years ago",
                 "an apple a day keeps the doctor away",];
my $num_sentences = scalar(@$sentences);

sub next_tuple {
    my ($self) = @_;

    $self->emit( [ $sentences->[ rand($num_sentences) ] ] );

}

To actually start your Spout, call the run method, which will initialize the Spout and start the event loop.

SentenceSpout->new->run;

Methods supported by Spouts and Bolts

Custom initialization

If you need to have some custom action happen when your component is being initialized, just override initialize method, which receives the Storm configuration for the component and information about its place in the topology as its arguments.

sub initialize {
    my ( $self, $storm_conf, $context ) = @_;
}

Logging

Use the log method to send messages back to the Storm ShellBolt parent process which will be added to the general Storm log.

sub process {
    my ($self, $tuple) = @_;
    ...
    $self->log("Working on $tuple");
    ...
}

AUTHORS

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Educational Testing Service.

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