Pg PubSub listen from a model

25 views
Skip to first unread message

John

unread,
May 27, 2019, 5:07:26 PM5/27/19
to mojol...@googlegroups.com
Hello,

From my model I want to listen for Pg PubSub messages.  I am passing
the helper "pg" into the model as a param after creating it:

   $self->helper( pg => sub { state $pg = Mojo::Pg->new( $config->{pg}
) } );

How do I listen for messages?  This compiles but doesn't do anything as
far as I can see:

    $self->pg->pubsub->listen(location_msg => sub {
        my ($pubsub, $payload) = @_;
        $self->log->debug('location: ' . Dumper($payload));
    });

Do I need to create a Mojo loop of some sort in my model?

John


Veesh Goldman

unread,
May 27, 2019, 11:45:02 PM5/27/19
to mojol...@googlegroups.com
Can't really tell, because you aren't showing enough code, so I would ask this: could you show the code that you're notifying the channel from?

--
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious...@googlegroups.com.
To post to this group, send email to mojol...@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
To view this discussion on the web visit https://groups.google.com/d/msgid/mojolicious/79407916-57d2-7233-3fe0-7cfbd3477c2c%40tonebridge.com.
For more options, visit https://groups.google.com/d/optout.

John

unread,
May 28, 2019, 12:12:56 PM5/28/19
to mojol...@googlegroups.com

John

unread,
May 28, 2019, 6:23:19 PM5/28/19
to mojol...@googlegroups.com

I figured out what I was doing wrong.   It was with the sending of notifications.   The condition was not being hit to send the message.  I did the basic debugging I should have done before contacting the mailing list.

John

Reply all
Reply to author
Forward
0 new messages