[Mojolicious] Mojo::ByteStream->split

2018-12-15 Thread Stefan Adams
Any chance the following update to Mojo::ByteStream->split would be
accepted?

sub split {
  my ($self, $pattern, $limit) = @_;
  return Mojo::Collection->new(map { $self->new($_) } split $pattern,
$$self, $limit//0);
}


My reason for needing this is that I need to parse a file into columns and
some of the columns at the end of a line are empty and being discarded.

$ perldoc -f split

If LIMIT is omitted (or, equivalently, zero), then it is usually
treated as if it were instead negative but with the exception
that
*trailing empty fields are stripped* (empty leading fields are
always preserved); if all fields are empty, then all fields are
considered to be trailing (and are thus stripped in this case).
Thus, the following:

print join(':', split(',', 'a,b,c,,,')), "\n";

produces the output 'a:b:c', but the following:

*print join(':', split(',', 'a,b,c,,,', -1)), "\n";*

*produces the output 'a:b:c:::'.*

I need to be able to get that last bold, and therefore need to pass -1 as
the limit.

-- 
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] plugin for scheduling Minion jobs (cron backend)

2018-12-15 Thread Stefan Adams
On Sat, Dec 15, 2018 at 12:31 PM sri  wrote:

> a) you can now just use cron to enqueue unique jobs for you, and
>>
>
Hmm...  I think you mean this command?

./myapp.pl minion job -e foo -P 10023 -P 10024 -p 5 -q important

So if I wanted the Mojolicious app to control the schedule, it would need
to maintain the Mojolicious app's running-user crontab file.

My app would need to do something along the lines of:

(crontab -l ; echo "0 * * * * /path/to/myapp.pl minion job -e foo -P 10023
-P 10024 -p 5 -q important") | crontab -


A plugin could be written to handle this with maybe the help of something
like Config::Crontab .  It could
also handle scheduling one-time jobs with `at`.

my $at = app->schedule->at(DateTime => 'job' => [@args]);
my $crontab = app->schedule->recurring('0 * * * *' => 'job' => [@args]);


And the Schedule plugin behind the scenes would execute `at` or `crontab`
accordingly.

You could delete the scheduled job with

app->schedule->remove($at, $contab, ...);


I'm thinking it would also be great to have a Mojo::Pg migrations-like
feature where it would make sure that the crontab has all of the necessary
jobs scheduled each time it launches.

app->schedule->migrations->name('clear_cache')->migrate(0)->migrate;


What do you think?  Does that sound reasonable?

>

-- 
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 - minion worker doesn't start automatically

2018-12-15 Thread sri

>
> On a maybe related-ish note, it would also be great if there was a way for 
> a Mojolicious app (or maybe Minion job) to do recurring tasks (think cron) 
> -- for example, purge a cache every hour on the hour or something...  I 
> think this was talked about regarding Minion a while back.  It would make 
> sense for Minion to handle the jobs, and of course the Mojolicious app 
> would need to be able to queue the job at a specific time via the Minion 
> plugin.  I haven't been able to do it because my task always ends up 
> getting scheduled by all of the forked workers.
>

A cron feature has been talked about for Minion. But i'm afraid we decided 
against it,
because a) you can now just use cron to enqueue unique jobs for you, and b) 
given
the distributed nature of Minion, implementing a cron that actually works 
is really
really hard.

--
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 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 - minion worker doesn't start automatically

2018-12-15 Thread Stefan Adams
OH MY GOSH PLEASE!!  :D

On a maybe related-ish note, it would also be great if there was a way for
a Mojolicious app (or maybe Minion job) to do recurring tasks (think cron)
-- for example, purge a cache every hour on the hour or something...  I
think this was talked about regarding Minion a while back.  It would make
sense for Minion to handle the jobs, and of course the Mojolicious app
would need to be able to queue the job at a specific time via the Minion
plugin.  I haven't been able to do it because my task always ends up
getting scheduled by all of the forked workers.

On Sat, Dec 15, 2018 at 11:45 AM sri  wrote:

> This is a planned feature.
>
> https://github.com/mojolicious/minion/issues/76
>
> --
> 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 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.


Re: [Mojolicious] Mojolicious - minion worker doesn't start automatically

2018-12-15 Thread sri
This is a planned feature.

https://github.com/mojolicious/minion/issues/76

--
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 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 - minion worker doesn't start automatically

2018-12-15 Thread Sachin Dangol
Thanks Stefan for clarifying.

I was thinking Minion can just be kept running automatically as long as web
app is running.

At work I am running minion manually and making sure it runs always. I was
thinking is it how experts do or any better ways I am missing.

Now I am clear. Thanks again.

On Saturday, December 15, 2018, Stefan Adams  wrote:

> Sachin, you said you haven't gotten any answer, but I see you and Corion
> had an exchange on SO some time earlier than this email.  Grinnz has since
> added a little extra as well.  What is currently commented on the
> Stackoverflow question between Corion and Grinnz looks like the appropriate
> response to me.  Is there anything else you are still needing help with?
>
> On Fri, Dec 14, 2018 at 9:12 PM Sachin Dangol 
> wrote:
>
>> I have asked this question on stackoverflow. Haven't got any answer.
>> Asking it here. Please help. I think I am missing something fundamental
>> here.
>>
>> 
>> https://stackoverflow.com/questions/53774276/mojolicious-minion-worker-
>> doesnt-start-automatically
>>
>> --
>> 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 a topic in the
> Google Groups "Mojolicious" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/mojolicious/uN-qgrr7g0s/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 https://groups.google.com/group/mojolicious.
> For more options, visit https://groups.google.com/d/optout.
>


-- 
thanks,
Sachin Dangol
+65 98123139
  

-- 
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.