Mojo::Client has been deprecated

173 views
Skip to first unread message

Sebastian Riedel

unread,
Mar 13, 2011, 6:00:20 AM3/13/11
to mojol...@googlegroups.com
Hi,

Most of you might have already seen it on Twitter and IRC, but i guess another warning doesn't hurt.
Mojo::Client has recently been deprecated in favor of the new module Mojo::UserAgent.

Reasons for this are simple, it is the only way to make some necessary fundamental changes to the non-blocking API without breaking backwards compatibility.
In compliance with our deprecation policies you will be able to use Mojo::Client for another major release, but there will be deprecation warnings all over the place and it will disappear after the deprecation period has ended.

The way we mixed blocking and non-blocking APIs in Mojo::Client has caused a lot of confusion in the past and just didn't work out.
So in Mojo::UserAgent everything will get simplified drastically.
All method calls without a callback are blocking, and you can append a callback to make them non-blocking (using Mojo::IOLoop->singleton).

# Blocking
my $tx = $ua->get('http://kraih.com');

# Non-blocking
$ua->get('http://kraih.com' => sub {
my $tx = pop;
Mojo::IOLoop->stop;
});
Mojo::IOLoop->start;

The new name has mostly been inspired by the terminology in RFC2616, one could say our old client has finally grown up to a user agent. ;)

So far everything is looking very good, but more testing would be very much appreciated.

--
Sebastian Riedel
http://mojolicio.us
http://twitter.com/kraih
http://blog.kraih.com


sri

unread,
Mar 14, 2011, 8:02:09 AM3/14/11
to Mojolicious
I've just released Mojolicious 1.13, so these changes are now live! :)
Reply all
Reply to author
Forward
0 new messages