Add support for the factors parameter in publisher.pl:

We can multiply the number of messages delivery by factor, thus allowing
to test support for publishing multiple messages

Signed-off-by: Pedro Melo <melo@simplicidade.org>
This commit is contained in:
Pedro Melo
2014-07-21 05:11:43 +01:00
parent 5bd01740ee
commit 1ff696d616

View File

@@ -12,6 +12,7 @@ my ($topic, $factor) = @ARGV;
die "Usage: publisher.pl topic [msgs_per_call]\n" unless $topic;
$factor = 1 unless $factor;
my @factors = (1 .. $factor);
my $cv = AE::cv;
@@ -36,7 +37,9 @@ my @readline;
chomp($line);
return unless length($line);
$r->publish($topic, "$c: $line");
my @messages = map {"$c.$_: $line"} @factors;
$r->publish($topic, @messages);
$c++;
$_[0]->push_read(@readline);
}