--- /dev/null
+package APKPM::Bitstream;
+
+use base qw(Gearman::Driver::Worker);
+use Moose;
+use Time::HiRes;
+use Data::Dump qw(dump);
+use LWP::Simple;
+use JSON::XS;
+
+with 'APKPM::Gearman';
+
+sub prefix { 'Bitstream_' }
+
+sub process_name {
+ my ( $self, $orig, $job_name ) = @_;
+ warn "# process_name $orig $job_name\n";
+ return "$orig ($job_name)";
+}
+
+sub poll : Job : Encode(e_json) {
+ my ( $self, $job, $workload ) = @_;
+
+ my $content = get 'http://172.18.0.38/bs_ip_lookup';
+ my $json = decode_json $content;
+
+ my @users;
+
+ foreach my $cpe ( @{ $json->{bs_ip_lookup} } ) {
+ if ( $cpe->{username} =~ m/h1dsl-flat/ ) {
+ warn "SKIP: ",dump($cpe) if $ENV{DEBUG};
+ } else {
+ push @users, $cpe;
+ }
+ }
+
+ warn "# poll = ",dump( @users );
+
+ return [ @users ];
+}
+
+1;
--- /dev/null
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+use Test::More tests => 3;
+use Data::Dump qw(dump);
+
+use lib 'lib';
+
+use_ok 'APKPM::Bitstream';
+
+ok my $o = APKPM::Bitstream->new( server => 'localhost:4730' ), 'new';
+
+ok my $r = $o->poll( 'job', '' ), 'poll';
+diag dump($r);
+