| 1 | # ABSTRACT: The base class for all IO::Storm Spout. | ||||||||||||||||||
| 2 | |||||||||||||||||||
| 3 | package IO::Storm::Spout; | ||||||||||||||||||
| 4 | 1 | $IO::Storm::Spout::VERSION = '0.17'; | |||||||||||||||||
| 5 | # Imports | ||||||||||||||||||
| 6 | 1 | ▶ | use strict; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 7 | 1 | ▶ | use warnings; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 8 | 1 | ▶ | use v5.10; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 9 | |||||||||||||||||||
| 10 | 1 | ▶ | use Moo; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 11 | 1 | ▶ | use namespace::clean; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 12 | |||||||||||||||||||
| 13 | 1 | extends 'IO::Storm::Component'; | |||||||||||||||||
| 14 | |||||||||||||||||||
| 15 | |||||||||||||||||||
| 16 | 0 | ▶ | sub initialize { | ||||||||||||||||
|
Subroutine
initialize: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 17 | 0 | my ( $self, $storm_conf, $context ) = @_; | |||||||||||||||||
| 18 | } | ||||||||||||||||||
| 19 | |||||||||||||||||||
| 20 | |||||||||||||||||||
| 21 | 0 | ▶ | sub ack { | ||||||||||||||||
|
Subroutine
ack: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 22 | 0 | my ( $self, $id ) = @_; | |||||||||||||||||
| 23 | } | ||||||||||||||||||
| 24 | |||||||||||||||||||
| 25 | |||||||||||||||||||
| 26 | 0 | ▶ | sub fail { | ||||||||||||||||
|
Subroutine
fail: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 27 | 0 | my ( $self, $id ) = @_; | |||||||||||||||||
| 28 | } | ||||||||||||||||||
| 29 | |||||||||||||||||||
| 30 | |||||||||||||||||||
| 31 | 0 | ▶ | sub next_tuple { | ||||||||||||||||
|
Subroutine
next_tuple: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 32 | 0 | my ($self) = @_; | |||||||||||||||||
| 33 | } | ||||||||||||||||||
| 34 | |||||||||||||||||||
| 35 | |||||||||||||||||||
| 36 | 1 | ▶ | sub emit ($$;$) { | ||||||||||||||||
|
Subroutine
emit: called CC=6 SCAR=27.7
Pod
documented
| |||||||||||||||||||
| 37 | 1 | my ( $self, $tuple, $args ) = @_; | |||||||||||||||||
| 38 | |||||||||||||||||||
| 39 | 1 | my $msg = { command => 'emit', tuple => $tuple }; | |||||||||||||||||
| 40 | |||||||||||||||||||
| 41 | 1 | ▶ | if ( defined($args) ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 42 | 0 | ▶ | if ( defined( $args->{tup_id} ) ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 43 | 0 | $msg->{id} = $args->{tup_id}; | |||||||||||||||||
| 44 | } | ||||||||||||||||||
| 45 | 0 | ▶ | if ( defined( $args->{stream} ) ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 46 | 0 | $msg->{stream} = $args->{stream}; | |||||||||||||||||
| 47 | } | ||||||||||||||||||
| 48 | 0 | ▶ | if ( defined( $args->{direct_task} ) ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 49 | 0 | $msg->{task} = $args->{direct_task}; | |||||||||||||||||
| 50 | } | ||||||||||||||||||
| 51 | } | ||||||||||||||||||
| 52 | |||||||||||||||||||
| 53 | 1 | $self->send_message($msg); | |||||||||||||||||
| 54 | |||||||||||||||||||
| 55 | 1 | ▶ | if ( defined $msg->{task} ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 56 | 0 | return $msg->{task}; | |||||||||||||||||
| 57 | } | ||||||||||||||||||
| 58 | else { | ||||||||||||||||||
| 59 | 1 | return $self->read_task_ids(); | |||||||||||||||||
| 60 | } | ||||||||||||||||||
| 61 | } | ||||||||||||||||||
| 62 | |||||||||||||||||||
| 63 | |||||||||||||||||||
| 64 | 0 | ▶ | sub run { | ||||||||||||||||
|
Subroutine
run: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||
| 65 | 0 | my ($self) = @_; | |||||||||||||||||
| 66 | |||||||||||||||||||
| 67 | 0 | my ( $storm_conf, $context ) = $self->read_handshake(); | |||||||||||||||||
| 68 | 0 | $self->_setup_component( $storm_conf, $context ); | |||||||||||||||||
| 69 | 0 | $self->initialize( $storm_conf, $context ); | |||||||||||||||||
| 70 | |||||||||||||||||||
| 71 | 0 | while (1) { | |||||||||||||||||
| 72 | 0 | my $msg = $self->read_command(); | |||||||||||||||||
| 73 | 0 | ▶ | if ( $msg->{command} eq 'next' ) { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 74 | 0 | $self->next_tuple; | |||||||||||||||||
| 75 | } | ||||||||||||||||||
| 76 | elsif ( $msg->{command} eq 'ack' ) { | ||||||||||||||||||
| 77 | 0 | $self->ack( $msg->{id} ); | |||||||||||||||||
| 78 | } | ||||||||||||||||||
| 79 | elsif ( $msg->{command} eq 'fail' ) { | ||||||||||||||||||
| 80 | 0 | $self->fail( $msg->{id} ); | |||||||||||||||||
| 81 | } | ||||||||||||||||||
| 82 | 0 | $self->sync(); | |||||||||||||||||
| 83 | } | ||||||||||||||||||
| 84 | } | ||||||||||||||||||
| 85 | |||||||||||||||||||
| 86 | 1 | 1; | |||||||||||||||||
| 87 | |||||||||||||||||||
| 88 | __END__ | ||||||||||||||||||