Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package perl-Mojo-Redis for openSUSE:Factory
checked in at 2022-03-08 20:32:20
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-Mojo-Redis (Old)
and /work/SRC/openSUSE:Factory/.perl-Mojo-Redis.new.2349 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Mojo-Redis"
Tue Mar 8 20:32:20 2022 rev:7 rq:960194 version:3.29
Changes:
--------
--- /work/SRC/openSUSE:Factory/perl-Mojo-Redis/perl-Mojo-Redis.changes
2021-11-27 00:52:35.502539521 +0100
+++
/work/SRC/openSUSE:Factory/.perl-Mojo-Redis.new.2349/perl-Mojo-Redis.changes
2022-03-11 11:50:01.846891562 +0100
@@ -1,0 +2,12 @@
+Thu Feb 24 03:08:29 UTC 2022 - Tina M??ller <[email protected]>
+
+- updated to 3.29
+ see /usr/share/doc/packages/perl-Mojo-Redis/Changes
+
+ 3.29 2022-02-23T14:56:18+0900
+ - Fix use of "defined" in unit test
+
+ 3.28 2022-02-21T15:40:56+0900
+ - Add channel to Mojo::Redis::PubSub::listen() callback
+
+-------------------------------------------------------------------
Old:
----
Mojo-Redis-3.27.tar.gz
New:
----
Mojo-Redis-3.29.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ perl-Mojo-Redis.spec ++++++
--- /var/tmp/diff_new_pack.OmYNdV/_old 2022-03-11 11:50:02.286892079 +0100
+++ /var/tmp/diff_new_pack.OmYNdV/_new 2022-03-11 11:50:02.290892084 +0100
@@ -1,7 +1,7 @@
#
# spec file for package perl-Mojo-Redis
#
-# Copyright (c) 2021 SUSE LLC
+# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -18,10 +18,10 @@
%define cpan_name Mojo-Redis
Name: perl-Mojo-Redis
-Version: 3.27
+Version: 3.29
Release: 0
-Summary: Redis driver based on Mojo::IOLoop
License: Artistic-2.0
+Summary: Redis driver based on Mojo::IOLoop
URL: https://metacpan.org/release/%{cpan_name}
Source0:
https://cpan.metacpan.org/authors/id/J/JH/JHTHORSEN/%{cpan_name}-%{version}.tar.gz
Source1: cpanspec.yml
++++++ Mojo-Redis-3.27.tar.gz -> Mojo-Redis-3.29.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Mojo-Redis-3.27/Changes new/Mojo-Redis-3.29/Changes
--- old/Mojo-Redis-3.27/Changes 2021-11-20 02:51:49.000000000 +0100
+++ new/Mojo-Redis-3.29/Changes 2022-02-23 06:56:18.000000000 +0100
@@ -1,5 +1,11 @@
Revision history for perl distribution Mojo-Redis
+3.29 2022-02-23T14:56:18+0900
+ - Fix use of "defined" in unit test
+
+3.28 2022-02-21T15:40:56+0900
+ - Add channel to Mojo::Redis::PubSub::listen() callback
+
3.27 2021-11-20T10:51:49+0900
- Add experimental "subscribe" and "psubscribe" events to Mojo::Redis::PubSub
- Fix examples for set and expire #62
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Mojo-Redis-3.27/META.json
new/Mojo-Redis-3.29/META.json
--- old/Mojo-Redis-3.27/META.json 2021-11-20 02:51:50.000000000 +0100
+++ new/Mojo-Redis-3.29/META.json 2022-02-23 06:56:19.000000000 +0100
@@ -53,7 +53,7 @@
"web" : "https://github.com/jhthorsen/mojo-redis"
}
},
- "version" : "3.27",
+ "version" : "3.29",
"x_contributors" : [
"Jan Henning Thorsen <[email protected]>",
"Dan Book <[email protected]>"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Mojo-Redis-3.27/META.yml new/Mojo-Redis-3.29/META.yml
--- old/Mojo-Redis-3.27/META.yml 2021-11-20 02:51:50.000000000 +0100
+++ new/Mojo-Redis-3.29/META.yml 2022-02-23 06:56:18.000000000 +0100
@@ -25,7 +25,7 @@
bugtracker: https://github.com/jhthorsen/mojo-redis/issues
homepage: https://github.com/jhthorsen/mojo-redis
repository: https://github.com/jhthorsen/mojo-redis.git
-version: '3.27'
+version: '3.29'
x_contributors:
- 'Jan Henning Thorsen <[email protected]>'
- 'Dan Book <[email protected]>'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Mojo-Redis-3.27/README.md
new/Mojo-Redis-3.29/README.md
--- old/Mojo-Redis-3.27/README.md 2021-11-20 02:51:49.000000000 +0100
+++ new/Mojo-Redis-3.29/README.md 2022-02-23 06:56:18.000000000 +0100
@@ -9,7 +9,7 @@
use Mojo::Redis;
my $redis = Mojo::Redis->new;
$redis->db->set(foo => 42);
- $redis->expire(foo => 600);
+ $redis->db->expire(foo => 600);
warn $redis->db->get('foo');
## Promises
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Mojo-Redis-3.27/lib/Mojo/Redis/PubSub.pm
new/Mojo-Redis-3.29/lib/Mojo/Redis/PubSub.pm
--- old/Mojo-Redis-3.27/lib/Mojo/Redis/PubSub.pm 2021-11-20
02:48:14.000000000 +0100
+++ new/Mojo-Redis-3.29/lib/Mojo/Redis/PubSub.pm 2022-02-21
07:39:33.000000000 +0100
@@ -113,12 +113,20 @@
my ($self, $conn, $res) = @_;
$self->emit(reconnect => $conn) if delete $self->{reconnect};
+ # $res = [pmessage => $name, $channel, $data]
+ # $res = [message => $channel, $data]
+
return unless ref $res eq 'ARRAY';
return $self->emit(@$res) unless $res->[0] =~ m!^p?message$!i;
- my ($psub) = $res->[0] eq 'pmessage' ? splice @$res, 1, 1 : ();
- $res->[2] = eval { from_json $res->[2] } if $self->{json}{$res->[1]};
- my $keyspace_listen = $self->{keyspace_listen}{$psub || $res->[1]};
- for my $cb (@{$self->{chans}{$psub || $res->[1]}}) {
$self->$cb($keyspace_listen ? [@$res[1, 2]] : $res->[2]) }
+
+ my ($name) = $res->[0] eq 'pmessage' ? splice @$res, 1, 1 :
($res->[1]);
+ my $keyspace_listen = $self->{keyspace_listen}{$name};
+
+ local $@;
+ $res->[2] = eval { from_json $res->[2] } if $self->{json}{$name};
+ for my $cb (@{$self->{chans}{$name} || []}) {
+ $self->$cb($keyspace_listen ? [@$res[1, 2]] : $res->[2], $res->[1]);
+ }
}
sub _reconnect {
@@ -150,8 +158,8 @@
my $pubsub = $redis->pubsub;
$pubsub->listen("user:superwoman:messages" => sub {
- my ($pubsub, $message) = @_;
- say "superwoman got a message: $message";
+ my ($pubsub, $message, $channel) = @_;
+ say "superwoman got a message '$message' from channel '$channel'";
});
$pubsub->notify("user:batboy:messages", "How are you doing?");
@@ -266,7 +274,7 @@
# Send and receive data structures
$pubsub->json("foo")->listen(foo => sub {
- my ($pubsub, $payload) = @_;
+ my ($pubsub, $payload, $channel) = @_;
say $payload->{bar};
});
$pubsub->notify(foo => {bar => 'I ??? Mojolicious!'});
@@ -315,10 +323,15 @@
=head2 listen
- $cb = $pubsub->listen($channel => sub { my ($pubsub, $message) = @_ });
+ $cb = $pubsub->listen($channel => sub { my ($pubsub, $message, $channel) =
@_ });
+
+Subscribe to an exact channel name
+(L<SUBSCRIBE|https://redis.io/commands/subscribe>) or a channel name with a
+pattern (L<PSUBSCRIBE|https://redis.io/commands/psubscribe>). C<$channel> in
+the callback will be the exact channel name, without any pattern. C<$message>
+will be the data published to that the channel.
-Subscribe to a channel, there is no limit on how many subscribers a channel
-can have. The returning code ref can be passed on to L</unlisten>.
+The returning code ref can be passed on to L</unlisten>.
=head2 notify
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Mojo-Redis-3.27/lib/Mojo/Redis.pm
new/Mojo-Redis-3.29/lib/Mojo/Redis.pm
--- old/Mojo-Redis-3.27/lib/Mojo/Redis.pm 2021-11-20 02:51:49.000000000
+0100
+++ new/Mojo-Redis-3.29/lib/Mojo/Redis.pm 2022-02-23 06:56:18.000000000
+0100
@@ -9,7 +9,7 @@
use Mojo::Redis::PubSub;
use Scalar::Util 'blessed';
-our $VERSION = '3.27';
+our $VERSION = '3.29';
$ENV{MOJO_REDIS_URL} ||= 'redis://localhost:6379';
@@ -110,7 +110,7 @@
use Mojo::Redis;
my $redis = Mojo::Redis->new;
$redis->db->set(foo => 42);
- $redis->expire(foo => 600);
+ $redis->db->expire(foo => 600);
warn $redis->db->get('foo');
=head2 Promises
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Mojo-Redis-3.27/t/pubsub.t
new/Mojo-Redis-3.29/t/pubsub.t
--- old/Mojo-Redis-3.27/t/pubsub.t 2021-11-20 02:37:47.000000000 +0100
+++ new/Mojo-Redis-3.29/t/pubsub.t 2022-02-23 06:52:55.000000000 +0100
@@ -1,94 +1,118 @@
use Mojo::Base -strict;
use Test::More;
+use Mojo::JSON qw(encode_json);
use Mojo::Redis;
plan skip_all => 'TEST_ONLINE=redis://localhost' unless $ENV{TEST_ONLINE};
-*memory_cycle_ok = eval 'require Test::Memory::Cycle;1' ?
\&Test::Memory::Cycle::memory_cycle_ok : sub { };
-
-my $redis = Mojo::Redis->new($ENV{TEST_ONLINE});
-my $db = $redis->db;
-memory_cycle_ok($redis, 'cycle ok for Mojo::Redis');
+*memory_cycle_ok
+ = eval 'require Test::Memory::Cycle;1' ?
\&Test::Memory::Cycle::memory_cycle_ok : sub { ok 1, 'memory_cycle_ok' };
+my $redis = Mojo::Redis->new($ENV{TEST_ONLINE});
+my $db = $redis->db;
my $pubsub = $redis->pubsub;
-my (@messages, @res);
-memory_cycle_ok($redis, 'cycle ok for Mojo::Redis::PubSub');
-
-my @events;
-$pubsub->on(error => sub { shift; push @events, [error => @_] });
-$pubsub->on(psubscribe => sub { shift; push @events, [psubscribe => @_] });
-$pubsub->on(subscribe => sub { shift; push @events, [subscribe => @_] });
-
-is ref($pubsub->listen("rtest:$$:1" => \&gather)), 'CODE', 'listen';
-$pubsub->listen("rtest:$$:2" => \&gather);
-note 'Waiting for subscriptions to be set up...';
-Mojo::IOLoop->timer(0.15 => sub { Mojo::IOLoop->stop });
-Mojo::IOLoop->start;
-memory_cycle_ok($redis, 'cycle ok after listen');
-
-$pubsub->notify("rtest:$$:1" => 'message one');
-$db->publish_p("rtest:$$:2" => 'message two')->wait;
-memory_cycle_ok($redis, 'cycle ok after notify');
-
-is_deeply [sort @messages], ['message one', 'message two'], 'got messages' or
diag join ", ", @messages;
-
-$pubsub->channels_p('rtest*')->then(sub { @res = @_ })->wait;
-is_deeply [sort @{$res[0]}], ["rtest:$$:1", "rtest:$$:2"], 'channels_p';
-
-$pubsub->numsub_p("rtest:$$:1")->then(sub { @res = @_ })->wait;
-is_deeply $res[0], {"rtest:$$:1" => 1}, 'numsub_p';
-
-$pubsub->numpat_p->then(sub { @res = @_ })->wait;
-is_deeply $res[0], 0, 'numpat_p';
-
-is $pubsub->unlisten("rtest:$$:1", \&gather), $pubsub, 'unlisten';
-memory_cycle_ok($pubsub, 'cycle ok after unlisten');
-$db->publish_p("rtest:$$:1" => 'nobody is listening to this');
-
-note 'Making sure the last message is not received';
-Mojo::IOLoop->timer(0.15 => sub { Mojo::IOLoop->stop });
-Mojo::IOLoop->start;
-is_deeply [sort @messages], ['message one', 'message two'], 'got messages' or
diag join ", ", @messages;
-
-note 'test listen patterns';
-@messages = ();
-$pubsub->listen("rtest:$$:*" => \&gather);
-Mojo::IOLoop->timer(
- 0.2 => sub {
- $pubsub->notify("rtest:$$:4" => 'message four');
- $pubsub->notify("rtest:$$:5" => 'message five');
- }
-);
-Mojo::IOLoop->start;
-
-is_deeply [sort @messages], ['message five', 'message four'], 'got messages'
or diag join ", ", @messages;
-$pubsub->unlisten("rtest:$$:*");
-
-my $conn = $pubsub->connection;
-is @{$conn->subscribers('response')}, 1, 'only one message subscriber';
-
-undef $pubsub;
-delete $redis->{pubsub};
-isnt $redis->db->connection, $conn, 'pubsub connection cannot be re-used';
-
-note 'test json data';
-@messages = ();
-$pubsub = $redis->pubsub;
-$pubsub->json("rtest:$$:1");
-$pubsub->listen("rtest:$$:1" => \&gather);
-Mojo::IOLoop->timer(
- 0.2 => sub {
- $pubsub->notify("rtest:$$:1" => {some => 'data'});
- $pubsub->notify("rtest:$$:1" => 'just a string');
- }
-);
-Mojo::IOLoop->start;
-is_deeply \@messages, [{some => 'data'}, 'just a string'], 'got json messages';
+my (@events, @messages, @res);
-is_deeply [sort { $a cmp $b } map { $_->[0] } @events], [qw(psubscribe
subscribe subscribe)], 'events';
+subtest memory => sub {
+ memory_cycle_ok($redis, 'cycle ok for Mojo::Redis');
+ memory_cycle_ok($redis, 'cycle ok for Mojo::Redis::PubSub');
+};
+
+subtest events => sub {
+ $pubsub->on(error => sub { shift; push @events, [error => @_] });
+ $pubsub->on(psubscribe => sub { shift; push @events, [psubscribe => @_] });
+ $pubsub->on(subscribe => sub { shift; push @events, [subscribe => @_] });
+
+ is ref($pubsub->listen("rtest:$$:1" => \&gather)), 'CODE', 'listen';
+ $pubsub->listen("rtest:$$:2" => \&gather);
+ note 'Waiting for subscriptions to be set up...';
+ Mojo::Promise->timer(0.15)->wait;
+ memory_cycle_ok($redis, 'cycle ok after listen');
+};
+
+subtest notify => sub {
+ $pubsub->notify("rtest:$$:1" => 'message one');
+ $db->publish_p("rtest:$$:2" => 'message two')->wait;
+ memory_cycle_ok($redis, 'cycle ok after notify');
+ has_messages("rtest:$$:1/message one", "rtest:$$:2/message two");
+};
+
+subtest channels => sub {
+ $pubsub->channels_p('rtest*')->then(sub { @res = @_ })->wait;
+ is_deeply [sort @{$res[0]}], ["rtest:$$:1", "rtest:$$:2"], 'channels_p';
+};
+
+subtest numsub => sub {
+ $pubsub->numsub_p("rtest:$$:1")->then(sub { @res = @_ })->wait;
+ is_deeply $res[0], {"rtest:$$:1" => 1}, 'numsub_p';
+};
+
+subtest numpat => sub {
+ $pubsub->numpat_p->then(sub { @res = @_ })->wait;
+ is_deeply $res[0], 0, 'numpat_p';
+};
+
+subtest unlisten => sub {
+ is $pubsub->unlisten("rtest:$$:1", \&gather), $pubsub, 'unlisten';
+ memory_cycle_ok($pubsub, 'cycle ok after unlisten');
+ $db->publish_p("rtest:$$:1" => 'nobody is listening to this');
+
+ note 'Making sure the last message is not received';
+ Mojo::Promise->timer(0.15)->wait;
+ has_messages();
+};
+
+subtest 'listen patterns' => sub {
+ $pubsub->listen("rtest:$$:*" => \&gather);
+ Mojo::Promise->timer(0.1)->wait;
+
+ $pubsub->notify("rtest:$$:4" => 'message four');
+ $pubsub->notify("rtest:$$:5" => 'message five');
+ wait_for_messages(2);
+
+ has_messages("rtest:$$:5/message five", "rtest:$$:4/message four");
+ $pubsub->unlisten("rtest:$$:*");
+};
+
+subtest connection => sub {
+ my $conn = $pubsub->connection;
+ is @{$conn->subscribers('response')}, 1, 'only one message subscriber';
+
+ undef $pubsub;
+ delete $redis->{pubsub};
+ isnt $redis->db->connection, $conn, 'pubsub connection cannot be re-used';
+};
+
+subtest 'json data' => sub {
+ $pubsub = $redis->pubsub;
+ $pubsub->listen("rtest:$$:1" => \&gather);
+ Mojo::Promise->timer(0.1)->wait;
+
+ $pubsub->notify_p("rtest:$$:1" => '{"invalid"');
+ $pubsub->json("rtest:$$:1");
+ $pubsub->notify("rtest:$$:1" => {some => 'data'});
+ $pubsub->notify("rtest:$$:1" => 'just a string');
+ wait_for_messages(3);
+
+ has_messages("rtest:$$:1/undef", qq(rtest:$$:1/HASH/{"some":"data"}),
"rtest:$$:1/just a string");
+};
+
+subtest events => sub {
+ is_deeply [sort { $a cmp $b } map { $_->[0] } @events], [qw(psubscribe
subscribe subscribe)], 'events';
+};
done_testing;
sub gather {
- push @messages, $_[1];
- Mojo::IOLoop->stop if @messages == 2;
+ shift;
+ push @messages, join '/', map { !defined($_) ? 'undef' : ref($_) ? (ref($_),
encode_json($_)) : $_ } reverse @_;
+}
+
+sub has_messages {
+ is_deeply [sort @messages], [sort @_], 'has messages' or diag explain
\@messages;
+ @messages = ();
+}
+
+sub wait_for_messages {
+ my $n = shift;
+ Mojo::IOLoop->one_tick until @messages >= $n;
}