Re: [Mojolicious] Pg PubSub listen from a model

2019-05-28 Thread John
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


On 5/28/19 11:12 AM, John wrote:


Code that does the notification:

https://github.com/john-/telem_control/blob/d192bd24eef370868944830f3d54ace9ca3ed081/lib/TelemControl/Model/Sensors/GPS.pm#L48


That notify is similar on what is in the base class:

https://github.com/john-/telem_control/blob/d192bd24eef370868944830f3d54ace9ca3ed081/lib/TelemControl/Model/Sensors/Base.pm#L185


Model code that attempts to receive the pubsub messages:

https://github.com/john-/telem_control/blob/d192bd24eef370868944830f3d54ace9ca3ed081/lib/TelemControl/Model/Sensors/Weather.pm#L22


Thanks,


John



On 5/27/19 10:44 PM, Veesh Goldman wrote:
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?


On Tue, May 28, 2019, 12:07 AM John > wrote:


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


-- 
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+unsubscr...@googlegroups.com
.
To post to this group, send email to mojolicious@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.

--
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+unsubscr...@googlegroups.com 
.
To post to this group, send email to mojolicious@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/CAO-W_8DDh%2BDWAB%2BBWdPNqvc_UbMxHHVR6SJmetzWErHcixKvbg%40mail.gmail.com 
.

For more options, visit https://groups.google.com/d/optout.


--
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+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@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/d8e61be1-c828-a6b6-7e4c-9a340fa5a9e8%40tonebridge.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Pg PubSub listen from a model

2019-05-28 Thread John

Code that does the notification:

https://github.com/john-/telem_control/blob/d192bd24eef370868944830f3d54ace9ca3ed081/lib/TelemControl/Model/Sensors/GPS.pm#L48


That notify is similar on what is in the base class:

https://github.com/john-/telem_control/blob/d192bd24eef370868944830f3d54ace9ca3ed081/lib/TelemControl/Model/Sensors/Base.pm#L185


Model code that attempts to receive the pubsub messages:

https://github.com/john-/telem_control/blob/d192bd24eef370868944830f3d54ace9ca3ed081/lib/TelemControl/Model/Sensors/Weather.pm#L22


Thanks,


John



On 5/27/19 10:44 PM, Veesh Goldman wrote:
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?


On Tue, May 28, 2019, 12:07 AM John > wrote:


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


-- 
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+unsubscr...@googlegroups.com
.
To post to this group, send email to mojolicious@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.

--
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+unsubscr...@googlegroups.com 
.
To post to this group, send email to mojolicious@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/CAO-W_8DDh%2BDWAB%2BBWdPNqvc_UbMxHHVR6SJmetzWErHcixKvbg%40mail.gmail.com 
.

For more options, visit https://groups.google.com/d/optout.


--
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+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@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/193e5c7c-196b-88f9-6943-91fc95c6cb62%40tonebridge.com.
For more options, visit https://groups.google.com/d/optout.