package MQR::Redis;

use AnyEvent::Redis;
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 @_ } );
}

sub publish {
	my ( $channel, $body ) = @_;
	$channel = join(' ', @$channel) if ref $channel eq 'ARRAY';
	my $pub = redis;
	$pub->publish( $channel, $body );
	warn ">>>> ",dump($channel, $body);
}

1;
