another refactor to use MSG and SEND all over
[MQR.git] / lib / MQR / Redis.pm
index 119cb46..8835471 100644 (file)
@@ -5,11 +5,13 @@ use Carp qw(confess);
 use Data::Dump qw(dump);
 
 sub redis {
-       AnyEvent::Redis->new( host => $ENV{REDIS_HOST}, port => $ENV{REDIS_PORT}, on_error => sub { confess @_ } );
+       my $redis = AnyEvent::Redis->new( host => $ENV{REDIS_HOST}, port => $ENV{REDIS_PORT}, on_error => sub { confess @_ } );
+       $redis->ping;
+       return $redis;
 }
 
 sub publish {
-       my ( $channel, $body ) = @_;
+       my ( $self, $channel, $body ) = @_;
        $channel = join(' ', @$channel) if ref $channel eq 'ARRAY';
        my $pub = redis;
        $pub->publish( $channel, $body );