Move publish() public API to Client, even Readers get to publish sometimes

Signed-off-by: Pedro Melo <melo@simplicidade.org>
This commit is contained in:
Pedro Melo committed 2014-07-21 05:16:17 +01:00
1 parent 0d8f13b950
commit cfa7a7b4a5
2 files changed
+19 -18

No files matched your search

-18
View File
@@ -10,23 +10,5 @@ use Carp 'croak';
use parent 'AnyEvent::NSQ::Client';
#### Producer API
## Publish a single or multiple message - callback is only called if we succedd
sub publish {
my ($self, $topic, @data) = @_;
my $conn = $self->_random_connected_conn;
croak "ERROR: there no active connections at this moment," unless $conn;
if (ref($data[-1]) eq 'CODE' or !defined($data[-1])) {
my $cb = pop @data;
push @data, sub { $cb->($self, $topic, \@data, @_) }
if $cb;
}
return $conn->publish($topic, @data);
}
1;