Alvis-Pipeline

 view release on metacpan or  search on metacpan

lib/Alvis/Logger.pm  view on Meta::CPAN

#		be silent except for priority-zero messages, which are
#		really error messages).
#	stream [stderr]: where to write messages
#	
sub new {
    my $class = shift();
    #warn("new($class): \@_ = ", join(", ", map { "'$_'" } @_), "\n");
    my %options = ( level => 0, stream => \*STDERR, @_ );
    $options{level} = 0 if !defined $options{level};

    return bless {
	options => \%options,
    }, $class;
}


# Log a message.  The first argument is the priority of the message,
# the remainder are strings that will be concatenated to form the
# message.
#
sub log {

lib/Alvis/Pipeline/Read.pm  view on Meta::CPAN

use warnings;
use IO::File;
use IO::Socket::INET;
use Fcntl qw(:flock);


sub new {
    my $class = shift();
    my(%opts) = @_;

    my $this = bless {}, $class;
    $this->{spooldir} = delete $opts{spooldir}
	or die "new($class) with no spooldir";
    $this->{port} = delete $opts{port}
	or die "new($class) with no port";

    $this->_setopts(sleep => 10, %opts);

    # Asynchronicity: server process accepts pushes and stores them
    $this->log(1, "forking");
    my $pid = fork();

lib/Alvis/Pipeline/Read.pm  view on Meta::CPAN

    use Carp;
    seek($fh, 0, SEEK_SET) or confess "can't seek to start of '$seqfile': $!";
    $fh->print("$lastread $lastwrite\n") or die "can't rewrite '$seqfile': $!";
    flock($fh, LOCK_UN) or die "can't unlock '$seqfile': $!";
    $fh->close() or die "Truly unbelievable";
    $this->log(3, "put lastread='$lastread', lastwrite='$lastwrite'");
}


# Test harness follows
#	my $p = bless {
#	    spooldir => "/tmp/ap",
#	}, "Alvis::Pipeline::Read";
#	
#	if (@ARGV) {
#	    $p->_store_file(join("", @ARGV));
#	} else {
#	    my $doc = $p->read();
#	    die "no document queued" if !defined $doc;
#	    print $doc;
#	}

lib/Alvis/Pipeline/Write.pm  view on Meta::CPAN

@ISA = qw(Alvis::Pipeline);

use strict;
use warnings;


sub new {
    my $class = shift();
    my(%opts) = @_;

    my $this = bless {}, $class;
    $this->{host} = delete $opts{host}
	or die "new($class) with no host";
    $this->{port} = delete $opts{port}
	or die "new($class) with no port";

    $this->_setopts(%opts);
    $this->{socket} = new IO::Socket::INET(PeerAddr => $this->{host},
					   PeerPort => $this->{port},
					   Proto => "tcp")
	or die("can't connect to '" . $this->{host} . "', ",



( run in 2.049 seconds using v1.01-cache-2.11-cpan-b32c08c6d1a )