Re: [Mojolicious] Websocket cat

2019-12-15 Thread John
Thanks for both your responses.  I will look at user agent.

On Sun, Dec 15, 2019, 10:57 AM Felipe Gasper 
wrote:

> I’ve spent very little time with Mojo as a WS client, but I found the
> example in Mojo::UserAgent’s documentation to be enough to get me where I
> needed to go.
>
> =
> $ua->websocket('ws+unix://%2Ftmp%2Fmyapp.sock/echo.json' => sub {
>   my ($ua, $tx) = @_;
>   say 'WebSocket handshake failed!' and return unless $tx->is_websocket;
>   $tx->on(json => sub {
> my ($tx, $hash) = @_;
> say "WebSocket message via JSON: $hash->{msg}";
> $tx->finish;
>   });
>   $tx->send({json => {msg => 'Hello World!'}});
> });
> Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
> =
>
> ^^ So, specify remote server and port in the wss:// URL.
>
> -FG
>
>
> > On Dec 15, 2019, at 11:38 AM, John  wrote:
> >
> > I am trying to get my head around using mojolicious as a websocket
> client.  I have used it as a websocket server in various projects.   To
> start I wanted to create a simple command line utility that connected to a
> websocket server and printed the json it received.
> >
> > I began with the documentation:
> >
> > https://mojolicious.org/perldoc/Mojo/IOLoop/Stream/WebSocketClient
> >
> > Due to my lack of understanding the basics a couple things confuse me.
>  Where do I specify the remote server/port and how do I define $handle?
>  My code is pretty much the example at that location but with "use
> warnings/strict" added.I haven't been able to get an understanding
> based on my review of the docs.
> >
> > It would be great to see an example as I expect others have done this
> before.   Otherwise some pointers wold be appreciated.
> >
> > Thanks,
> >
> > 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/mojolicious/cc400d5f-e7e2-1595-70e5-94ff1974eb27%40tonebridge.com
> .
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/mojolicious/052B04A6-DAB2-4412-9F1A-4C935D1CD263%40felipegasper.com
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/mojolicious/CANUwEqkjZuTek2rMEgZc2xMutqDFYp9LM_DJH_xydBCvA9buQQ%40mail.gmail.com.


[Mojolicious] Websocket cat

2019-12-15 Thread John
I am trying to get my head around using mojolicious as a websocket 
client.  I have used it as a websocket server in various projects.   To 
start I wanted to create a simple command line utility that connected to 
a websocket server and printed the json it received.


I began with the documentation:

https://mojolicious.org/perldoc/Mojo/IOLoop/Stream/WebSocketClient

Due to my lack of understanding the basics a couple things confuse me.   
Where do I specify the remote server/port and how do I define $handle?   
My code is pretty much the example at that location but with "use 
warnings/strict" added.    I haven't been able to get an understanding 
based on my review of the docs.


It would be great to see an example as I expect others have done this 
before.   Otherwise some pointers wold be appreciated.


Thanks,

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 view this discussion on the web visit 
https://groups.google.com/d/msgid/mojolicious/cc400d5f-e7e2-1595-70e5-94ff1974eb27%40tonebridge.com.


Re: [Mojolicious] Mojolicious Web Clients Book

2019-11-29 Thread John
My pre-order was just cancelled by Amazon.  No specific reason given.

On Fri, Nov 29, 2019, 6:09 AM Zakarias Santanu  wrote:

> The link doesn’t work
>
> On 21 Nov 2019, at 16.17, sri  wrote:
>
> You can now pre-order the book brian d foy announced at Mojoconf.
>
> https://www.amazon.com/gp/product/B0815XLYJX/
>
> --
> sebastian
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/mojolicious/21938b5f-9092-4a9a-85c3-35dc549bbba5%40googlegroups.com
> 
> .
>
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/mojolicious/8F02C357-B22D-4007-86BB-86C6C6F701F7%40gmail.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/mojolicious/CANUwEqko67Y%3DR%2BzPnSxUpXeTdhmhhdWwY-GObD4FKh00%3Dw1iDA%40mail.gmail.com.


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 <mailto:j...@tonebridge.com>> 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
<mailto:mojolicious%2bunsubscr...@googlegroups.com>.
To post to this group, send email to mojolicious@googlegroups.com
<mailto: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 
<mailto:mojolicious+unsubscr...@googlegroups.com>.
To post to this group, send email to mojolicious@googlegroups.com 
<mailto: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 
<https://groups.google.com/d/msgid/mojolicious/CAO-W_8DDh%2BDWAB%2BBWdPNqvc_UbMxHHVR6SJmetzWErHcixKvbg%40mail.gmail.com?utm_medium=email_source=footer>.

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 <mailto:j...@tonebridge.com>> 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
<mailto:mojolicious%2bunsubscr...@googlegroups.com>.
To post to this group, send email to mojolicious@googlegroups.com
<mailto: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 
<mailto:mojolicious+unsubscr...@googlegroups.com>.
To post to this group, send email to mojolicious@googlegroups.com 
<mailto: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 
<https://groups.google.com/d/msgid/mojolicious/CAO-W_8DDh%2BDWAB%2BBWdPNqvc_UbMxHHVR6SJmetzWErHcixKvbg%40mail.gmail.com?utm_medium=email_source=footer>.

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.


[Mojolicious] Pg PubSub listen from a model

2019-05-27 Thread John

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.


[Mojolicious] Re: Minion hangs sometimes. No idea of reason

2019-03-27 Thread John Scoles
What type of "Minion" are you using?

I ran into the same sort of thing with very long running scripts under 
'Pg'  I changed over to a simple Sereal => $file  and that solved the 
problem at least for me

hope this help


On Wednesday, March 27, 2019 at 11:47:49 AM UTC-4, Alex Povolotsky wrote:
>
> It's a common worker, running a complex job. Without a minion, job runs OK 
> (well... I'll need to make an extensive test of it to be sure), but when 
> running in Minion, it gets locked at a random point.
>
> среда, 27 марта 2019 г., 18:21:35 UTC+3 пользователь sri написал:
>>
>> Could you be any more vague? You're saying "Minion hangs sometimes", so 
>> am i to
>> assume you mean the manager process? But then you throw around random 
>> topics
>> like database locks, Mojo::UserAgent and complex code. So is it just a 
>> job? Or did you
>> build a custom worker? Nothing you wrote makes any sense.
>>
>> Anyway, nobody has ever reported problems with Minion workers hanging, 
>> and there
>> are setups that have processed billions of jobs with hundreds of workers.
>>
>> --
>> sebastian
>>
>
-- 
The contents of this e-mail and any attachments are intended solely for the 
use of the named addressee(s) and may contain confidential and/or 
privileged information. Any unauthorized use, copying, disclosure, or 
distribution of the contents of this e-mail is strictly prohibited by the 
sender and may be unlawful. If you are not the intended recipient, please 
notify the sender immediately and delete this e-mail.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Mojolicious learning curve for a catalyst migrant

2019-01-03 Thread john napiorkowski
Hi Rajesh,

I'm also a long time Catalyst user (10+ years) who is exploring
Mojolicious.  The 'TD;DR' version of this is that you really need to
try making an application and see for yourself.  The docs are great
compared to Catalyst and there's a goodly number of example
applications around you can look at to get the idea.  It really will
depend a lot on what you like and miss from Catalyst.  That will help
you determine if you want to stay with Perl, or if the effort of
learning a new framework might push you to jump ship to a different
language.  On that matter I won't speak.

Here's what I can see as the list of major differences:

1) Full stack versus 'TIMTOWTDI'.  Catalyst, despite having a
reputation as a heavyweight framework, is actually pretty minimal.  It
doesn't even build in basics like static file support.  Mojolicous
builds in everything you need (session support, views, etc) for your
week one+ development.  On the other hand Catalyst offers a lot more
choices for components like Views and Sessions for example.
(Mojolicous does have alternative Views but its pretty clear to me (or
at least to me) that the Mojolicous community prefers you use the
approved Mojolicious stack of stuff.  This even extends to using
Mojo::Base as your class builder (if you like Moose or Moo there's
nothing stopping you but I get the feeling like that's considered
'going off the reservation'.)  There's pros and cons to both
approaches, you have to decide what works for your style and if you
don't mind a walled garden approach.

2) Dependency count.  Catalyst will require installing a lot of
dependencies to get to a useful workable place.  Like I said,
Mojolicious gives you a ton of stuff with a single dependency.  If you
find managing Perl dependencies hard you might like that.  Even though
I personally don't find it hard I will say it was nice to note have to
deal with it when starting a new project.  With Catalyst I find I
spend the first few hours of a new project setting up boilerplate.
That's a one time effort but it was nice to not have to worry about
it.  I'd also say that some of the built in Mojolicous stuff (like the
great static file handling) made me immediately jealous.

3) Routing.  Catalyst controllers use method attributes for routing,
Mojolicous has an API that you use to declare routes programatically.
This is probably the biggest visual difference.  If you absolutely
loved the Catalyst approach you will likely find the Mojolicous
approach cumbersome for large numbers of routes (at least at first).
On the other hand in consulting on many Catalyst applications its
clear to me that many people find the Catalyst way difficult to
understand.  So you might find the Routes API a breath of fresh air.
I'm still wondering if its suitable for application with large number
of routes, but again you have to try it yourself (and look at some
example applications with lots of routes and how people tried to
handle that to see if that seems a reasonable compromise to you).

4) Catalyst Components (Models, etc) versus Helpers.  Catalyst models
are pretty powerful and in expert hands you can do a lot with minimal
boilerplate code.  For example Catalyst will auto load and instantiate
models for you and you can control the instance lifespan. Its possible
to cleanly decouple your application from a particular instance class,
for example.  But the API is complex and again as a consultant on many
Catalyst applications its clear to me most people never learn to use
it properly.  Mojolicous Helpers are much easier to grasp immediately
and with a little munging can basically do most of the same thing,
minus the autoloading and automatic binding of configuration values.
You probably end up writing more boilerplate but people seem to
understand it better.  This is probably my biggest sore point coming
from Catalyst FWIW.  I find Mojolicous helpers encourage writing to an
instance not an interface but I am sure others will strongly disagree.
And FWIW everything about helpers I don't love could be fixed.

5) Advanced web features and support for async.  You mentioned stuff
like web sockets, etc.  Catalyst will never see that without effort
that clearly doesn't exist.  If you need those things then Mojolicious
is the only game in town for Perl that is production grade.  Catalyst
has experimental support for that stuff but its mostly there as a
pointer to what needs to be fixed in order to make it production
worthy.  I haven't looked but I would say Dancer would have to be the
same since both are limited by PSGI.

6) Long term?  Catalyst currently has no development goals, team, etc.
It does everything well it did well yesterday.  You can see that as a
pro or as a con.  If you are building an application for someone that
doesn't want to maintain it then Catalyst might be a good choice since
it has always emphasized long term compatibility.  As a consultant on
many Catalyst applications I've seen people upgrade after years
without 

Re: [Mojolicious] Odd Behavior with Websocket

2018-12-02 Thread john



On 11/27/18 12:24 PM, john wrote:


I created an application which I feel reproduces the problem.   If I 
use Mojo::IOLoop::Subprocess in a specfic way it causes the Websocket 
code to behave erratically.   I feel like I am using the framework as 
intended but if not this will hopefully provide some insight into 
what I am doing wrong.




This issue is now resolved based on feedback in this issue:

    https://github.com/mojolicious/mojo/issues/1297

Per that thread I changed my code by storing the Websocket's PID and 
then comparing it to the PID that emitted the on finish event.


websocket '/ws' => sub {
    my $self = shift;

    my $me = $$;

    app->log->debug(sprintf 'Client connected: %s', $self->tx);

    $self->on(finish => sub {
    return unless $$ == $me;
    app->log->debug('Client disconnected');
    });
};


--
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.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Odd Behavior with Websocket

2018-11-27 Thread john


Also note that in my full application I am pretty sure that even though 
the websocket on finish event handler is being hit the connection is 
still up and running.   I can still send messages over the connection.


On 11/27/18 12:11 PM, john wrote:



On 11/27/18 6:09 AM, john wrote:


I will try and create a simplified application that exhibits the 
behavior (or doesn't).


I created an application which I feel reproduces the problem. If I use 
Mojo::IOLoop::Subprocess in a specfic way it causes the Websocket code 
to behave erratically.   I feel like I am using the framework as 
intended but if not this will hopefully provide some insight into what 
I am doing wrong.


What the code does:

- every few seconds execute a Subprocess

- starts a websocket listener when browser connects

Steps to reproduce:

- start the program "./notify daemon"

- Wen browser access the application the handler code immediately hits 
the on finish event ("Client disconnected")


Here is the code:

https://gist.github.com/john-/ac496cc2dd1e33adff8cee6438fe6240

Thing of note:

- The "Client disconnected" messages repeat with every iteration of 
the IOLoop until


- You don't need to actually do the "system(@args)" to cause the failure.

- Comment out the Subprocess->run section and things work as expected

- I am pretty sure I used ForkCall instead of Subprocess and things 
behaved the same so issue is not specific to ForkCall.


John



John

On 11/27/18 12:46 AM, Stefan Adams wrote:
Is it possible that the issue you are experiencing is related to 
this <https://github.com/mojolicious/mojo-pg/issues/50> and which 
was assumed to be solved by this 
<https://github.com/mojolicious/mojo-pg/pull/51>, and therefore 
possibly a direct consequence of that commit?  kraih intended to 
deprecate pubsub and jberger swooped in to save the day, but it 
seems that it was known to be not well tested (just my observation 
from the mailing list / GitHub issues).


Are you experiencing these issues with Mojo::Pg 4.11? Seems the 
answer to that would shed a lot of light on the above.


On Mon, Nov 26, 2018 at 9:38 PM john <mailto:j...@tonebridge.com>> wrote:


Hello,

I have controller code that subscribes to Mojo::Pg::PubSub
messages and
sends messages via Websocket based on that subscription.
However, It
appears to me that the Websocket on finish is getting hit when a
Mojo::PubSub messages comes in to listen handler.  Even then the
Websocket is not really closed. If I comment out the
pubsub->unlisten
more messages come in and get delivered to the client.

Yeah, I am doing something wrong.   I have not distilled it down
to a
simple scenario so it could be my problem originates outside
this code.

The "output" sub is where I see this behavior:


https://github.com/john-/telem_control/blob/084347f18bdfd69ae6b32b20fc7013786ac23bce/lib/TelemControl/Controller/Main.pm#L21

Every time a message comes in the on finish for the Websocket is
hit.
Typical log pattern:

[2018-11-26 21:27:57.82505] [2976] [debug] WebSocket for details
closed
in output handler(1006)
[2018-11-26 21:27:59.07773] [2955] [debug] item to let client
know about
(pubsub): audio

This same pattern repeats for every message that comes in via
pubsub.

Yes, there is probably more happening here than I am saying but
that is
what I understand at the moment.

I am using Mojolicious-8.07 and Mojo-Pg-4.12.

Thanks,

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
<mailto:mojolicious%2bunsubscr...@googlegroups.com>.
To post to this group, send email to
mojolicious@googlegroups.com <mailto:mojolicious@googlegroups.com>.
Visit this group at https://groups.google.com/group/mojolicious.
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 
<mailto:mojolicious+unsubscr...@googlegroups.com>.
To post to this group, send email to mojolicious@googlegroups.com 
<mailto:mojolicious@googlegroups.com>.

Visit this group at https://groups.google.com/group/mojolicious.
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 em

Re: [Mojolicious] Odd Behavior with Websocket

2018-11-27 Thread john
I experienced it in prior versions of Mojo::Pg.   I just tested in 4.11 
with same results.   I will try and create a simplified application that 
exhibits the behavior (or doesn't).


John

On 11/27/18 12:46 AM, Stefan Adams wrote:
Is it possible that the issue you are experiencing is related to this 
<https://github.com/mojolicious/mojo-pg/issues/50> and which was 
assumed to be solved by this 
<https://github.com/mojolicious/mojo-pg/pull/51>, and therefore 
possibly a direct consequence of that commit?  kraih intended to 
deprecate pubsub and jberger swooped in to save the day, but it seems 
that it was known to be not well tested (just my observation from the 
mailing list / GitHub issues).


Are you experiencing these issues with Mojo::Pg 4.11? Seems the answer 
to that would shed a lot of light on the above.


On Mon, Nov 26, 2018 at 9:38 PM john <mailto:j...@tonebridge.com>> wrote:


Hello,

I have controller code that subscribes to Mojo::Pg::PubSub
messages and
sends messages via Websocket based on that subscription. However, It
appears to me that the Websocket on finish is getting hit when a
Mojo::PubSub messages comes in to listen handler.  Even then the
Websocket is not really closed. If I comment out the pubsub->unlisten
more messages come in and get delivered to the client.

Yeah, I am doing something wrong.   I have not distilled it down to a
simple scenario so it could be my problem originates outside this
code.

The "output" sub is where I see this behavior:


https://github.com/john-/telem_control/blob/084347f18bdfd69ae6b32b20fc7013786ac23bce/lib/TelemControl/Controller/Main.pm#L21

Every time a message comes in the on finish for the Websocket is hit.
Typical log pattern:

[2018-11-26 21:27:57.82505] [2976] [debug] WebSocket for details
closed
in output handler(1006)
[2018-11-26 21:27:59.07773] [2955] [debug] item to let client know
about
(pubsub): audio

This same pattern repeats for every message that comes in via pubsub.

Yes, there is probably more happening here than I am saying but
that is
what I understand at the moment.

I am using Mojolicious-8.07 and Mojo-Pg-4.12.

Thanks,

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
<mailto:mojolicious%2bunsubscr...@googlegroups.com>.
To post to this group, send email to mojolicious@googlegroups.com
<mailto:mojolicious@googlegroups.com>.
Visit this group at https://groups.google.com/group/mojolicious.
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 
<mailto:mojolicious+unsubscr...@googlegroups.com>.
To post to this group, send email to mojolicious@googlegroups.com 
<mailto:mojolicious@googlegroups.com>.

Visit this group at https://groups.google.com/group/mojolicious.
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.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Odd Behavior with Websocket

2018-11-26 Thread john

Hello,

I have controller code that subscribes to Mojo::Pg::PubSub messages and 
sends messages via Websocket based on that subscription.  However, It 
appears to me that the Websocket on finish is getting hit when a 
Mojo::PubSub messages comes in to listen handler.  Even then the 
Websocket is not really closed. If I comment out the pubsub->unlisten 
more messages come in and get delivered to the client.


Yeah, I am doing something wrong.   I have not distilled it down to a 
simple scenario so it could be my problem originates outside this code.


The "output" sub is where I see this behavior:

https://github.com/john-/telem_control/blob/084347f18bdfd69ae6b32b20fc7013786ac23bce/lib/TelemControl/Controller/Main.pm#L21

Every time a message comes in the on finish for the Websocket is hit.   
Typical log pattern:


[2018-11-26 21:27:57.82505] [2976] [debug] WebSocket for details closed 
in output handler(1006)
[2018-11-26 21:27:59.07773] [2955] [debug] item to let client know about 
(pubsub): audio


This same pattern repeats for every message that comes in via pubsub.

Yes, there is probably more happening here than I am saying but that is 
what I understand at the moment.


I am using Mojolicious-8.07 and Mojo-Pg-4.12.

Thanks,

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.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Understanding shift->

2018-11-24 Thread john



On 11/24/18 2:51 PM, Dan Book wrote:
The shift function removes and returns the first argument from @_ 
(since there's no array passed for it to shift from) in a sub. It's 
used this way because the first argument to these subs is the 
invocant/object. You can replace it with $_[0] to get the first 
argument without removing it. You should not use $self from outside 
unless necessary because that may create a circular reference and leak 
memory.

Thanks.  I totally missed that it was being used in a sub in those cases.

--
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.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Understanding shift->

2018-11-24 Thread john

This probably a perl question so if I should ask elsewhere let me know...

In looking at the Mojo::Pg blog example and in recent addition of db 
method to Mojo::Pg::PubSub I see use of shift->.



From Mojo::Pg::PubSub documentation:

# Reconnect immediately
$pubsub->unsubscribe('disconnect')->on(disconnect => sub { shift->db });

Or from the blog example:

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

This doesn't work in my code and I replace "shift" with "$self".   That 
appears to be working.   Also, I can't reconcile using shift in this way 
and what the perl documentation says about it but could get over this if 
it worked.


What am I missing here?

Thanks,

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.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Pg::PubSub in full application

2018-11-23 Thread john

Hello,

I have previously used lite based applications and am starting to get 
familiar with full applications.   I have been struggling to understand 
how to implement Pg::PubSub across different parts of my application.   
My questions probably apply to any publish/subscribe implementation.  I 
have things working (messages are received by the controller) however it 
feels messy to me.


I have code like this in the controller:

package TelemControl::Controller::Main;
use Mojo::Base 'Mojolicious::Controller';

use Mojo::Pg;
use Mojo::Pg::PubSub;

our $pg = Mojo::Pg->new('postgresql://script@/db');
our $pubsub = Mojo::Pg::PubSub->new(pg => $pg);

in the controller client handler:

    my $cb = $pubsub->listen(
    sensor_msg => sub {
    my ( $pubsub, $payload ) = @_;
    my $msg = decode_json($payload);
    $c = $c->send( { json => $msg } );
    $c->app->log->debug(
    "item to let client know about (pubsub): $msg->{type}");
    }
    );

In my model:

sub new {
    my ($class, $log, $config) = @_;

    my $pg = Mojo::Pg->new('postgresql://script@/db')
    or $log->error('Could not connect to database');

    my $pubsub =  Mojo::Pg::PubSub->new(pg => $pg);

    my $self = {
    log => $log,
    config => $config,
    pubsub => $pubsub,
    pg => $pg,
    };

    bless $self, $class;

    return $self;
}

and then publish like this:

$self->{pubsub}->notify( sensor_msg => encode_json($results[0]) );


Questions:

-   Is there a better approach to this?   It would seem like with the 
way I did the controller every client that connects may bring up an 
additional database connection?  Or is it bad for other reasons?


-  I tried various ways to inject the pubsub into model and controllers 
(e.g. helpers) but could not get that to work.    Do I need to try 
harder on that front?


Thanks,

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.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Re: Call for posts: Advent Calendar 2018!

2018-11-16 Thread john napiorkowski
It might be a bit long for an Advent article but I was thinking to cleanup 
/ complete https://github.com/jjn1056/MojoCoin which is a Mojolicious port 
of a similar project written in Catalyst 
(https://github.com/jjn1056/Blockchain) and intended as a blockchain / 
cryptotoken learning example.  I figured now I know a bit more I can 
'mojo-fy' it a bit more (use native Validation objects and as many 
Mojolicous built-ins as possible).  If we think its too long we could split 
it over two articles (one for the intro and client code / wallet and the 
second for the server code /miner code.  

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Good namespace for personal plugin?

2018-05-08 Thread John Scoles
In a word 'yes' it is a bad idea


http://prepan.org/



PrePAN - Social Reviewing for Perl Modules
prepan.org
PrePAN provides a place to discuss your modules. Are there any similar ones? 
I'm not confident about the implementation... How can I distribute the module 
in keeping with CPAN's conventions?


is a good place to check such things.


Personal namespaces are to be avoided except where there are encouraged


Such as in Dist-Zilla plugin bundles


I might be acceptable to but all of you stuff in a top name-space like 
Mojolicious::Che or alike but then I dont' control it






From: mojolicious@googlegroups.com  on behalf of 
Luc Didry 
Sent: May 8, 2018 9:43 AM
To: Mojolicious
Subject: [Mojolicious] Good namespace for personal plugin?

Hello,

I have a few plugins that I wrote for my softwares and that I use
amongst different projects. They are not published on CPAN.

For now, I copy them in my projects and I have to update in my
differents projects each time they evolve.

A better way for that would be to publish them and update them from
CPAN.

1. Would it be an acceptable thing? (I don't want to pollute CPAN or
Mojolicious::Plugin namespace)
2. What would be a good namespace for those plugins? Would
Mojolicious::Plugin::XXX::NameOfThePlugin be OK? (with XXX something
personal)

Thanks for advices.
--
Luc
https://fiat-tux.fr/
[https://fiat-tux.fr/wp-content/themes/fiattux2013/images/headers/fiat-tux-banner.png]

Fiat Tux | Debian, GNU/Linux et geekeries en tout genre 
...
fiat-tux.fr
Le 14 juillet 2016, j’ai lancé mes pages Tipeee et Libe­ra­pay.. La récom­pense 
de base est l’ap­pa­ri­tion sur une page mensuelle de remer­cie­ments… voici 
celle de mars !



https://luc.frama.io/
Internet n'est pas compliqué, Internet est ce que vous en faites.

--
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.
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.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] nnouncing Mojolicious::Command::generate::routes_restsful and Mojolicious::Command::generate::routes_restsful_just_routes

2016-12-12 Thread John Scoles
Have a Hash get An app, Have a Hash get some code

https://metacpan.org/pod/Mojolicious::Command::generate::routes_restsful 
<https://metacpan.org/pod/distribution/Mojolicious-Plugin-Routes-Restful/lib/Mojolicious/Plugin/Routes/Restful.pm>

and 

https://metacpan.org/pod/Mojolicious::Command::generate::routes_restsful_just_routes

The next logical use for my 

https://metacpan.org/release/Mojolicious-Plugin-Routes-Restful

Great for those lazy programmer out there

enjoy!

Cheers
John

-- 


The contents of this e-mail and any attachments are intended solely for the use 
of the named addressee(s) and may contain confidential and/or privileged 
information. Any unauthorized use, copying, disclosure, or distribution of the 
contents of this e-mail is strictly prohibited by the sender and may be 
unlawful. If you are not the intended recipient, please notify the sender 
immediately and delete this e-mail.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Announcing Mojolicious Plugin RoutesRestful.pm

2016-11-29 Thread John Scoles
Have a hash get some routes

https://metacpan.org/pod/distribution/Mojolicious-Plugin-Routes-Restful/lib/Mojolicious/Plugin/Routes/Restful.pm

Version 0.02 is in the pipe and will soon replace vers 0.01 and it fixes a 
few little bugs and some very bad typos.

enjoy!

Cheers
John

-- 


The contents of this e-mail and any attachments are intended solely for the use 
of the named addressee(s) and may contain confidential and/or privileged 
information. Any unauthorized use, copying, disclosure, or distribution of the 
contents of this e-mail is strictly prohibited by the sender and may be 
unlawful. If you are not the intended recipient, please notify the sender 
immediately and delete this e-mail.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Namespace Question

2016-11-25 Thread John Scoles
Thanks Dan that helped

Also just found this article 
<http://perltricks.com/article/how-to-upload-a-script-to-cpan/>which was 
good as well

Will have to put me thinking cap on how I am going to package it might just 
do it as a generator which you can install that way.  

Cheers

On Tuesday, November 22, 2016 at 8:12:49 PM UTC-5, Dan Book wrote:
>
> If you want to put them on CPAN, you will at least need a dummy (empty) 
> module with a version number to make them installable. Once you decide on 
> that module name (something that Mojo core is not likely to want in the 
> future), you can put the templates inside that namespace. Another problem 
> however is making the templates usable once installed, as only 
> Mojolicious's own install path will automatically be used.
>
> I would recommend packaging it as a plugin, so that you can then have the 
> plugin add the installed path to the renderer's namespace, similar to in 
> the example here: 
> https://metacpan.org/pod/Mojolicious::Guides::Cookbook#Making-your-application-installable
>  
> (but don't change the application's home, just add your path to 
> @{$app->renderer->paths} ) Example:
>
> package My::Templates::Plugin;
> use Mojo::Base 'Mojolicious::Plugin';
> use File::Basename 'basename';
> use File::Spec::Functions 'catdir';
>
> sub register {
>   my ($self, $app, $config) = @_;
>   my $template_dir = catdir dirname(__FILE__), 'templates';
>   push @{$app->renderer->paths}, $template_dir;
> }
>
> You can also package the templates in a sharedir instead of in the lib 
> directory (note that only ExtUtils::MakeMaker will install arbitrary 
> templates in the lib directory, but all installers can use 
> File::ShareDir::Install). Then your plugin's register method would use 
> File::ShareDir or File::Share to find the installed sharedir.
>
> Hope this helps,
> -Dan
>
> On Tue, Nov 22, 2016 at 2:53 PM, John Scoles <sco...@cargotel.com 
> > wrote:
>
>>
>> I have a set of  AJAX web form templates that I think would most of us 
>> here at Mojolicious would enjoy using.
>>
>> I was going to put them up on CPAN but I do not know what name space to 
>> use for just a set of templates and are not tied to any specific App or 
>> controller.
>>
>> Couldn't find a space for them as they are just .ep files
>>
>> The only place I could think of was 
>>
>> *Mojolicious* 
>> <https://metacpan.org/source/SRI/Mojolicious-7.10/lib/Mojolicious> / 
>> *resources* 
>> <https://metacpan.org/source/SRI/Mojolicious-7.10/lib/Mojolicious/resources> 
>> / *templates* 
>> <https://metacpan.org/source/SRI/Mojolicious-7.10/lib/Mojolicious/resources/templates>
>>  
>> / mojo 
>>
>> any sugestions?? 
>>
>>
>>
>> The contents of this e-mail and any attachments are intended solely for the 
>> use of the named addressee(s) and may contain confidential and/or privileged 
>> information. Any unauthorized use, copying, disclosure, or distribution of 
>> the contents of this e-mail is strictly prohibited by the sender and may be 
>> unlawful. If you are not the intended recipient, please notify the sender 
>> immediately and delete this e-mail.
>>
>> -- 
>> 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.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
-- 


The contents of this e-mail and any attachments are intended solely for the use 
of the named addressee(s) and may contain confidential and/or privileged 
information. Any unauthorized use, copying, disclosure, or distribution of the 
contents of this e-mail is strictly prohibited by the sender and may be 
unlawful. If you are not the intended recipient, please notify the sender 
immediately and delete this e-mail.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Namespace Question

2016-11-22 Thread John Scoles

I have a set of  AJAX web form templates that I think would most of us here 
at Mojolicious would enjoy using.

I was going to put them up on CPAN but I do not know what name space to use 
for just a set of templates and are not tied to any specific App or 
controller.

Couldn't find a space for them as they are just .ep files

The only place I could think of was 

*Mojolicious* 
 / 
*resources* 
 
/ *templates* 

 
/ mojo 

any sugestions?? 



-- 


The contents of this e-mail and any attachments are intended solely for the use 
of the named addressee(s) and may contain confidential and/or privileged 
information. Any unauthorized use, copying, disclosure, or distribution of the 
contents of this e-mail is strictly prohibited by the sender and may be 
unlawful. If you are not the intended recipient, please notify the sender 
immediately and delete this e-mail.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Re: Keeping Route Logic Alive

2016-05-24 Thread John
On May 24, 2016 7:23 AM, "Heiko Jansen" <heiko.jansen...@gmail.com> wrote:

>
> I think it works like this:
> https://metacpan.org/source/SRI/Mojo-Pg-2.27/lib/Mojo/Pg/PubSub.pm#L14
keeps a reference to the callback inside the Mojo::Pg::PubSub object. And
the Mojo::Pg::PubSub object is referenced from Mojolicious. So the
reference counter of the callback does not reach 0.
> In your Inotifier code nothing outside wsinit() retains a reference to
the callback once wsinit() is left (the Inotifier::Model::FileWatch
theoretically might, but that object also gets destroyed when leaving
wsinit()).
>

That would explain it.  I may look at a similar approach for my code.

Thanks,

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.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Keeping Route Logic Alive

2016-05-24 Thread john

Hello,

In my test application (https://github.com/john-/mojo_inotifier) I am 
able to have a websocket client receive notifications when a file is 
added to a directory.


In order to get this to work I had to define my callback (n the route) 
with "our":


our $cb = $watcher->watch(
sub {
my $payload = shift;
$payload->{url} = $c->app->defaults->{audio_url};
$c = $c->send( { json => encode_json($payload) } );
}
);


If I define it with "my" then scope rules cause the variable (and 
therefore callback) to be lost.


What confuses me is that I was previously using Mojo::Pg::PubSub and 
this works:


my $cb = $c->pubsub->listen(msg => sub {
my ($pubsub, $payload) = @_;
my $msg = decode_json($payload);
$c = $c->send( { json => $msg } );
app->log->debug("item to let client know about (pubsub): $msg->{type}");
});

Why does "my" work in this case but not in the other?   It is not clear 
to me in reviewing Pg::PubSub code that there is anything different that 
would explain this.


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.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Re: Basic non-Lite WebSocket Application

2016-05-15 Thread john



On 05/15/2016 12:22 PM, Heiko Jansen wrote:


Try changing Actions.pm, L13 from
my $self => shift;
to
my $self = shift;


Oh my goodness.   That was it.

Thanks,

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.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Trouble Understanding Websockets Program Structure with Mojolicious

2016-01-01 Thread john
I am pretty new to Mojo so may be off base.  My first applications 
required users intact with a single back-end resource (hardware device) 
that was also under the control of the same application. Based on that 
wrong approach it looks like proper way is to use one application (not 
needed to be mojo) that does back-end processing. This application and a 
separate client side mojo/Websockets application would use IPC such as 
pub sub to interact.


John

On 12/30/2015 06:52 AM, Web Designer wrote:

I have the following parts to a system:

1 - price_alerts.html
2 - WSServer.pl
3 - WSConnector.pm
4 - CoreApplicationEngine.pm

Basically the CoreApplicationEngine.pm is constantly running and for 
arguments sake parsing data coming from text files (nothing to do with 
websockets).


I want to send updates to the browser page price_alerts.html - which 
works but I am not sure if I am going about it in the correct way.


This is the program flow:

CoreApplicationEngine.pm

--

package CoreApplicationEngine;

use WSConnector;
use threads;
...

sub priceParser {
my($self) = @_;

## Process some files here

## When a condition is met update any one browsing on the 
price_alerts.html page


my $WSConnector = new WSConnector();
my $thread = async {
$WSConnector->sendPriceAlert($price, $itemid, $item_name);
};
$thread->detach;

}



-

package WSConnector;

use Mojo::UserAgent;
use Mojo::IOLoop;
use JSON;

sub new {
my $class = shift;
my $ua= Mojo::UserAgent->new;
my $self  = { 'ua' => $ua };
bless $self, $class;
return $self;
}

sub sendPriceAlert {
my ($self, $price, $itemid, $item_name) = @_;
my $ua = $self->{ua};
my $data;
$data->{type} = "price_alert";
$data->{price} = $price;
$data->{itemid} = $itemid;
$data->{item_name} = $item_name;
my $json_data = encode_json($data);

$ua->websocket(
'ws://192.168.1.50:3000/prices' => sub {
my ( $ua, $tx ) = @_;
print 'WebSocket handshake failed!' and return unless 
$tx->is_websocket;

# Send a message to the server
$tx->send($json_return);
}
);
Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
}

sub otherAlertsHere { ... }




WSServer.pl

#!/usr/bin/perl -w
use strict;


use Mojolicious::Lite;
use JSON;

websocket '/prices' => sub {
my $c = shift;

# Opened
$c->app->log->debug('Prices WebSocket opened');

my $cli = sprintf( "%s", $c->tx );
$all_cli_txs->{$cli} = $c->tx; ## So I can broadcast to all 
connected browsers


# Increase inactivity timeout for connection a bit
$c->inactivity_timeout(1000);

# Incoming message
$c->on(
message => sub {
my ( $c, $msg ) = @_;
my $json = decode_json($msg);

## Process some data here and determine which 
subscribers to send to - broadcast, subset or single user - for 
example sake simply passing original json data here as $msg


if($json->{type} eq "price_alert"){
for my $client (keys %$all_cli_txs) {
$all_cli_txs->{$client}->send($msg);
}
}
}
}

$c->on(
finish => sub {
my ( $c, $code, $reason ) = @_;
$c->app->log->debug("WebSocket closed with status $code");
}
);
};

websocket '/otherthings' => sub {
my $c = shift;
## .. more

};



I will not post the javascript code on the front end as that is 
working without issue.


I have two main questions:

Question 1 - The code above works but eats memory. When running 1000s 
of updates a minutes, for example in a test, memory consumption rises 
until the whole system becomes unresponsive. This, I assume, is 
because of the thread async call to the WSConnector which is opening 
1000s of ws connections and not closing them.


So the first question is how do I use 'Mojo::IOLoop->stop;' to stop 
the ws client after a single send - I dont want a loop?


I have tried a few variations, like the following but cannot seem to 
get it to work:



sub sendPriceAlert {
my ($self, $price, $itemid, $item_name) = @_;
my $ua = $self->{ua};
my $data;
$data->{type} = "price_alert";
$data-&

Re: [Mojolicious] Form With Multiple Submit Buttons

2015-10-31 Thread john

Thanks.  I gave that method a try and it works well.

%= submit_button 'Submit', name => 'cmd', value => 'Play'
%= submit_button 'Submit', name => 'cmd', value => 'Pause'

In my controller:

my $cmd = lc($self->param('cmd'));

John

On 10/31/2015 11:30 AM, jay m wrote:


the button value only shows up in your URL if your form method=GET 
which isn't recommended in any case where form submission changes your 
application's state (i.e. if it results in a database update) or if 
the submitted info is sensitive, or long


also, a better solution, whether using GET or POST, is to give both 
buttons the same name and different values, and check the value in the 
controller that handles the route


jay


On Friday, October 30, 2015 at 9:44:40 PM UTC-4, jamadam wrote:





You will get URLs look like

?button1=push+it+for+foo 



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

Visit this group at http://groups.google.com/group/mojolicious.
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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Form With Multiple Submit Buttons

2015-10-30 Thread john

Perfect...thanks.

On 10/30/2015 08:44 PM, Keita Sugama wrote:

Hi John.

With this HTML




You will get URLs look like

?button1=push+it+for+foo

So you can detect which one has been pushed by checking the
existence of names in parameter.


On 2015/10/31 4:46, John wrote:

I am on path of a UI that is a single form with submit buttons for
various functions.  In a route I envision taking action based on what
button was selected.

  From Tag Helpers I can see how to assign properties to submit button:

%= submit_button 'Ok!', id => 'foo'

However it is not clear how I can key off id in my route.  The param
property doesn't seem to provide this information.

I am open to any suggestions including "don't do it that way do 
instead" or "this is basic html.  Learn that first".

Thanks,

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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Form With Multiple Submit Buttons

2015-10-30 Thread John
I am on path of a UI that is a single form with submit buttons for 
various functions.  In a route I envision taking action based on what 
button was selected.


From Tag Helpers I can see how to assign properties to submit button:

%= submit_button 'Ok!', id => 'foo'

However it is not clear how I can key off id in my route.  The param 
property doesn't seem to provide this information.


I am open to any suggestions including "don't do it that way do  
instead" or "this is basic html.  Learn that first".


Thanks,

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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] JSON is rendered twice

2015-02-16 Thread John


On 02/16/2015 06:36 AM, Magnificent Core wrote:

Hi all.

I've noticed, that when json is rendered, sometimes it's rendered 
actually twice.


Here's the code I have:
get '/test' = sub {
my $self =shift;
$self-render(data = encode_json {'a' = 'b'});
};


I bet the render and encode_json are doing something similar.

Try this:

$self-render(json = { a = 'b' } );

See docs for this render option.

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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Websocket Finish

2015-02-15 Thread John
In one of my applications I see the Websocket finish event fire off with 
quite often (seems like after every message to the client). The docs 
indicate this event gets fired off after every transaction:


http://mojolicio.us/perldoc/Mojo/Transaction/WebSocket#finish

Based on that it seems like the behaviour is expected.  However the 
Synopsis print this message on finish:  WebSocket closed with status $code.


Clearly the connection is not closed in my case because messages still 
continue to be sent to the client and I am not explicitly starting a new 
Websocket connection on the client side.


For what it is worth the error code is 1006 and the reason is undefined 
in this case.


What am I missing?

Thanks,

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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Re: Websocket Finish

2015-02-15 Thread John


On 02/15/2015 07:14 PM, sri wrote:


The docs
indicate this event gets fired off after every transaction:

http://mojolicio.us/perldoc/Mojo/Transaction/WebSocket#finish
http://mojolicio.us/perldoc/Mojo/Transaction/WebSocket#finish


Updated.

https://github.com/kraih/mojo/commit/581885e1b43a4d995781a8643fa44648fdbc49a3


Thanks for the clarification...I will do some more research into why the 
finish event gets fired off but socket is not closed...or at least why 
that appears to be the case.


--
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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] How to get the result of a finished Minion job back to the app

2015-02-03 Thread John


On 01/27/2015 05:23 AM, sri wrote:


I'm more or less exploring the possibilities of Minion. If it were
possible to get async notifications back, this would be a
magnificent way to bridge the sync and async worlds!


It used to be supported in the beginning, but didn't fit in very well.

  
https://github.com/kraih/minion/commit/2399f7b94be5a2e611b17df2c6b8e3b5eba040cb#diff-b30d9d6fe78ad2d38daed2446ba66d92L321

For most backends it would have to be done with a recurring timer 
trying to pull the result in regular intervals anyway. Which you can 
of course implement yourself as a helper in just a few lines too.



The first two mojolicious applications I have written now have the same 
pattern:  Web Socket client that should get instant notification when 
something managed by that same application generates events of interest 
to the client.


It would seem some kind of publish/subscribe type thing would be used 
here.  Can a third party module be grafted in or is there some 
fundamental reason why these kinds of applications aren't cleanly 
implemented?


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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] How to get the result of a finished Minion job back to the app

2015-01-27 Thread John


On 01/27/2015 05:23 AM, sri wrote:


For most backends it would have to be done with a recurring timer 
trying to pull the result in regular intervals anyway. Which you can 
of course implement yourself as a helper in just a few lines too.




Maybe I did this in an especially ugly way.  With Websockets I want real 
time updates to client:


https://github.com/john-/rtl_fm-scanner/blob/audio_manager/bin/rtl_fm-scanner#L180

Ideally it would be nice for the route to receive a message when 
something interesting happens (determined by logic associated with the 
long running process).


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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


RE: [Mojolicious] Re: Some basic questions + future

2015-01-05 Thread John Scoles
Yes it would be fine.  
 
As I use it for a similar conversion some time ago.
 
Word of wisdom  on this do not try to re-use the old CGI code  
 
Far faster to write new code with Mojo::upload.
 
Cheers
 
Date: Mon, 5 Jan 2015 14:18:34 -0800
From: mondote...@gmail.com
To: mojolicious@googlegroups.com
Subject: [Mojolicious] Re: Some basic questions + future

Thanks for answer.  I am thinking about moving my existing website which mainly 
rely on fast-cgi to mojolicious  hypnotoad with nginx as reverse proxy. Would 
you encourage use of mojolicious web framework for file-sharing type of website 
? I've already seen that it has Mojo::Upload tool for upload related stuff but 
it's not a big deal just very basic functions. Nothing related to download side 
at all.  So is mojolicious suitable for this kind of apps ?

Thanks.




-- 

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 http://groups.google.com/group/mojolicious.

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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Looking for input on my first Mojolicious program

2014-12-30 Thread john
Hello!

I have gotten a lot of help on irc and am at beginning stages of my first 
Mojolicious application.  I could use some more feedback.  What is done 
works but it is nowhere near complete.  I am open on anything from the 
design concerns to ways of fully utilizing Mojolicious idioms.

I have a big chink of comments in the section of code that concerns me 
most.  I couldn't figure out how to wait for changes in websocket client 
code when monitoring a long running process.

Here it is:

  https://github.com/john-/rtl_fm-scanner

This code will not work for you out of the box.  It requires hardware 
(rtl-sdr dongle) in addition to its very immature state.  Add comments to 
this thread or right into github.

Thanks.

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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Re: Getting data out via Websocket message handler

2014-12-26 Thread john
Updated version with code highlighting...

For sake of brevity here is snippet of code from working version.  I have 
an executable that runs for the life of the application and Websocket 
connections (from 1 or more clients) that need to get output from the 
executable.

Ideally the logic would be that once output from executable is available it 
would be sent to any clients that currently have a Websocket connection 
with the Mojolicious application.

use Mojolicious::Lite;
use Mojo::IOLoop;

use IO::Async::Process;
use IO::Async::Loop::Mojo;

my $loop = IO::Async::Loop::Mojo-new;

my $process = IO::Async::Process-new(
command = [ /bin/ping, localhost ],

stdout = {
on_read = sub {
my ( $stream, $buffref, $eof ) = @_;
while ( $$buffref =~ s/^(.*)\n// ) {
app-log-info(PING wrote: $1); 
# I Want to get $1 (or a modification of it) sent via the 
Websocket connection(s) $ws below.   
}
return 0;
},
},

on_finish = sub {
my ( $pid, $exitcode ) = @_;
my $status = ( $exitcode  8 );
   },
);

$loop-add($process);

websocket '/monitor' = sub {
my $self = shift;
$self-on(
json = sub {
my ( $ws, $row ) = @_;

my $html = $ws-render_to_string( 'table', rows = [$row] );
$ws-send( { json = { row = $html } } );

}
);
};

app-start;

How is this done in Mojolicious?

-- 
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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Re: Getting data out via Websocket message handler

2014-12-26 Thread john
It looks like Async::Selector does what I want:

  
http://search.cpan.org/~toshioito/Async-Selector-1.02/lib/Async/Selector/Example/Mojo.pod

Also, from irc here is another approach that may provide some insight:

  https://gist.github.com/jberger/78d7c1649d7acbab6a94


-- 
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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Websocket + Managing Child Process

2014-12-24 Thread john
Hello,

I am just starting out with Mojolicious.  I am trying to create an 
application that provides a Websocket interface to a child process managed 
by the application.  I started with the great example of a Websocket 
program here:

Joel's example 
http://www.google.com/url?sa=trct=jq=esrc=ssource=webcd=6cad=rjauact=8ved=0CEIQFjAFurl=http%3A%2F%2Fblogs.perl.org%2Fusers%2Fjoel_berger%2F2014%2F09%2Fmojolicious-do-it-for-the-candy.htmlei=vLuZVLqAEsGVNr-_gYgIusg=AFQjCNFDjyc9tu0Sl9K4Z2U5oKO41MqOvwbvm=bv.82001339,d.eXY

I started to modify it by stripping uneeded functions and adding code to 
manage the child process.  Here is that version (minus the html/javascript 
part which is currently unchanged from Joel's):

#!/usr/bin/env 
perl
   


use Mojolicious::Lite;
use Mojo::IOLoop;

use IO::Async::Process;
use IO::Async::Loop::Mojo;

my $loop = IO::Async::Loop::Mojo-new;

my $process = IO::Async::Process-new(
command = [ /bin/ping, -c4, localhost ],

stdout = {
on_read = sub {
my ( $stream, $buffref, $eof ) = @_;
while ( $$buffref =~ s/^(.*)\n// ) {
print PING wrote: $1\n;
}
return 0;
},
},

on_finish = sub {
my ( $pid, $exitcode ) = @_;
my $status = ( $exitcode  8 );

$loop-stop;
},
);

$loop-add($process);

# setup base 
route   
 

any '/' = sub {
my $self = shift;
my $rows;
push @$rows, [ 'col', 1 ];

$self-render( 'index', rows = $rows );
};

# setup websocket message 
handler 


websocket '/monitor' = sub {
my $self = shift;
$self-on(
json = sub {
my ( $ws, $row ) = @_;

my $html = $ws-render_to_string( 'table', rows = [$row] );
$ws-send( { json = { row = $html } } );

# Start recurring 
timer   


my $i  = 1;
my $id = Mojo::IOLoop-recurring(
1 = sub {

$html = $ws-render_to_string( 'table', rows = [$row] 
);
$ws-send( { json = { row = $html } } );
$self-finish if $i++ == 5;
}
);

# Stop recurring 
timer   
 

$self-on( finish = sub { Mojo::IOLoop-remove($id) } );

}
);
};

app-start;

The problem is if I leave the $loop-add($process); line in code the 
Websocket part doesn't work.  This is probably due to how I setup the 
IO::Async stuff.

Also, thinking ahead getting past this I would like the Websocket clients 
to interact with the child process (see the output of the single child and 
to restart it).  However, it is not clear how to do that in Mojolicious.

Yes, these are probably very basic things and any assistance is appreciated.

Thanks,

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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Re: Websocket + Managing Child Process

2014-12-24 Thread john
I got the basics working by removing the $loop-stop.  I can probably 
figure out how to get the Websocket part to interact with the spawned child 
on my own now that I have that working.

-- 
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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Re: Removal of render_exception and render_not_found (Mojolicious 6.0)

2014-12-07 Thread Revlin John
I have not figured out why the morbo command runs a version of mojolicious 
which is older than the one I've installed via cpan, but my work-around is to 
invoke my server script directly with the `daemon` option:

$ server.pl daemon

-- 
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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Re: Mojo::UserAgent submitting repeating fields

2014-11-14 Thread John Karr
Thanks Sebastian, 

I re-read the manpage you indicated yet another time and finally saw the 
answer. The modified example below works.

my $postquery = {
'fq'   = [ '{!geofilt pt=40.76,-74.00 sfield=latlong d=60}',  
'event_date:[NOW TO NOW+60DAY]' ],
'q'= '(*:*)',
'rows' = 100,
'wt'   = 'json'
};

-- 
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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Mojo::UserAgent submitting repeating fields

2014-11-13 Thread John Karr
I'm converting a model from using LWP to Mojo::UserAgent. In LWP I was able 
to use a balanced array ref instead of a hash ref to submit repeated form 
fields to my Solr Server, but this does not work with Mojo::UserAgent which 
seems to only accept a hashref for the post body. 

The data looks like this.
my $postquery = [
'fq'   = '{!geofilt pt=40.76,-74.00 sfield=latlong d=60}',
'fq'   = 'event_date:[NOW TO NOW+60DAY]',
'q'= '(*:*)',
'rows' = 100,
'wt'   = 'json'
];

The workaround would be to combine the fq fields.

-- 
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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


RE: [Mojolicious] Routing with Autorization

2014-10-17 Thread John Scoles
try using a plugin for that will cover 99.99% of what you may want to do
 
https://metacpan.org/release/Mojolicious-Plugin-Authorization
https://metacpan.org/pod/Mojolicious::Plugin::Authentication
 

 
Date: Fri, 17 Oct 2014 16:26:09 +0300
From: s...@alexbyk.com
To: mojolicious@googlegroups.com
Subject: Re: [Mojolicious] Routing with Autorization


  

  
  
If u wanna get an answer, you should
  provide a full example (a little app @gist will be good enough)

  

  I guess:

   $r-bridge('/')-to...


  but i'm not sure

  



  
my $authorized =
  $r-bridge()-to('auth#is_logged_in');



$authorized-get('/')-name('search')-to(template
  = 'search/search');


$authorized-get('/search')-name('search')-to(template
  = 'search/search');



$authorized-route('/search')-name('fetch')-to('search#fetch');
$authorized-route('/view/:action/')-name('action')-to('view#action');





In result without Autorization we have:



1) /search and / Virbidden from auth#is_logged_in it's good
2) /view/peoples/?id=12345 , /org/peoples/?id=12345 and etc
  is avalible and it's bad(



Why? And How to make this right?



  
  -- 

  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 http://groups.google.com/group/mojolicious.

  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 http://groups.google.com/group/mojolicious.

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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Re: streaming content (chunked)

2014-06-04 Thread John Saya
Thanks for the quick reply.  I did see that, but I guess I'm just not sure
how to get it working within my code.  Would you be able to show how to get
that working within IOLoop-server in my sample code?


On Wed, Jun 4, 2014 at 10:30 PM, sri kra...@googlemail.com wrote:

 I'm trying to create a simple server using Mojo, that can stream content
 back to a browser.


 You do know Mojolicious has native support for the chunked transfer
 encoding, right?


 http://mojolicio.us/perldoc/Mojolicious/Guides/Rendering#Chunked_transfer_encoding

 --
 sebastian

 --
 You received this message because you are subscribed to a topic in the
 Google Groups Mojolicious group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/mojolicious/JhtOtraArLI/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 mojolicious+unsubscr...@googlegroups.com.
 To post to this group, send email to mojolicious@googlegroups.com.
 Visit this group at http://groups.google.com/group/mojolicious.
 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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Mojolicious for the Internet of Things

2014-03-01 Thread John Dunlap
The one ring is a myth.
On Feb 28, 2014 7:04 PM, Stefan Adams ste...@cogentinnovators.com wrote:

 Is it possible for Mojolicious to be the core component in an Internet of
 Things solution?

 I want to build a device that is behind a firewall and I want a user who
 is also behind a firewall to connect to that device.  I assume that a cloud
 gateway would need to be leveraged.

 The user would connect with a web browser to the cloud and the device
 would connect to the cloud with some sort of a web client.  How now can the
 user connect to the device's web interface?

 Asked another way, could one build a Nest http://nest.com-type solution
 with Mojolicious powering the cloud as well as powering the device?

 I'm having a hard time visualizing how a random user web browser would be
 able to connect to a random device behind a firewall, even with a cloud
 gateway being used.

  --
 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 http://groups.google.com/group/mojolicious.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Mojolicious] Websocket scaling

2014-02-21 Thread John Dunlap
So, you're saying that I should run a separate instance of mojolicious for
each apache virtualhost? That seems to me like it defeats the point of
having a mojolicious http server in the first place.


On Fri, Feb 21, 2014 at 8:58 AM, Charlie Brady 
charlieb-m...@budge.apana.org.au wrote:


 On Wed, 19 Feb 2014, Cosimo Streppone wrote:

  On 02/19/2014 05:20 PM, John Dunlap wrote:
 
   2) I work for a SAAS provider and we use Apache virtualhosts to sell
 our
   software to our customers. As Mojolicious uses its own built in HTTP
   server, how do I achieve virtualhost-like behavior?
 
  You can run a Mojolicious app with Plack::Handler::Apache2
  under Apache + mod_perl.

 Probably easier to run the apps standalone and access via apache using
 mod_proxy.

 --
 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 http://groups.google.com/group/mojolicious.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/groups/opt_out.


[Mojolicious] Websocket scaling

2014-02-19 Thread John Dunlap
Currently, I'm working in mod_perl but I've been evaluating Mojolicious. 
One of the things that I find most attractive about Mojolicious is its 
support for websockets. However, I'm new to both mojolicious and to 
websockets and I have a few architectural concerns that could simply be the 
result of my ignorance. Either way, they are as follows,

1) How do I scale Mojolicious websockets horizontally?
2) I work for a SAAS provider and we use Apache virtualhosts to sell our 
software to our customers. As Mojolicious uses its own built in HTTP 
server, how do I achieve virtualhost-like behavior?

Cheers!
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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/groups/opt_out.


RE: [Mojolicious] Re: Help on RESTful routes

2014-01-24 Thread John Scoles
Hmm yes with a but.

 

You potentially have an endless number of controller .pm

 

much beter to throw all you cities in one controler with each city a sub

 

route-(cities/:action/show)--to(cities#show);

 

now instead of having to add a new controler for each city you only need a new 
sub of the city name?

 

the 'show'  in the ruout is not really needed IMHO

 

route-(cities/:action)--to(cities#show);


 



Date: Fri, 24 Jan 2014 11:40:56 -0800
From: lespaul7str...@gmail.com
To: mojolicious@googlegroups.com
Subject: [Mojolicious] Re: Help on RESTful routes





To answer my own question


for an route like this:
/cities/:id/neighborhoods/:id/:



All i have to do is to have an controller as city name and then construct the 
route like this
/cities/:controller/:action


then, when accessing 
/cities/paris/show 
it will pass through Paris.pm controller, action=show



-- 
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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/groups/opt_out.
  

-- 
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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/groups/opt_out.