package Qless::Workers;
=head1 NAME
Qless::Workers
=cut
use strict; use warnings;
use JSON::XS qw(decode_json);
use Time::HiRes qw();
use Qless::Utils qw(fix_empty_array);
sub new {
my $class = s
lts = decode_json($self->{'client'}->_workers([], Time::HiRes::time));
$results = fix_empty_array($results);
return $results;
}
sub item {
my ($self, $name) = @_;
my $rv = decode_json($self->{'cl
use warnings;
use base 'Qless::BaseJob';
use Qless::Utils qw(fix_empty_array);
use JSON::XS qw(decode_json encode_json);
use Class::Load qw(try_load_class);
use Time::HiRes qw();
sub new {
my $class
ient'}->_put([$queue],
$self->jid,
$self->klass,
encode_json($self->data),
Time::HiRes::time,
$delay||0,
'depends', encode_json($depends||[])
);
}
sub complete {
my ($self, $next, $dela
>worker_name, $self->queue_name,
Time::HiRes::time, encode_json($self->data), 'next', $next, 'delay', $delay||0, 'depends', encode_json($depends||[])
);
}
else {
return $self->client->_comple
ay()
p to print()
dd to Data::Dump::dd()
jd to JSON::XS::encode (utf8/pretty)
jl to JSON::XS::decode (utf8/allow nonref) a thing
xd to XML::Hash::LX::hash
;
use LWP::UserAgent;
use JSON;
use URI::Escape ();
# see http://www.pingdom.com/services/api-documentation-rest/
# use autodie;
# use MooseX::Params::Validate;
has '_json' => (
'is' =>
'ro',
'isa' => 'JSON',
'lazy' => 1,
'builder' => '_init_json',
);
has '_ua' => (
'is' => 'rw',
'isa' => 'LWP::UserAgent',
'lazy' => 1,
'builder' =>
nt('Pingdom::Client/0.01');
return $UA;
}
sub _init_json {
my $self = shift;
my $JSON = JSON::->new()->utf8();
return $JSON;
}
sub _set_lasterror {
my $self = shift;
my $c
package Qless::Client;
=head1 NAME
Qless::Client
=cut
use strict; use warnings;
use JSON::XS qw(decode_json);
use Sys::Hostname qw(hostname);
use Time::HiRes qw();
use Qless::Lua;
use Qless::Config
t
sub tags {
my ($self, $offset, $count) = @_;
$offset ||= 0;
$count ||= 100;
return decode_json($self->_tag([], 'top', $offset, $count));
}
=head2 C<event - TBD>
Listen for a single event
=cu
less::RecurringJob
=cut
use strict; use warnings;
use base 'Qless::BaseJob';
use JSON::XS qw(decode_json encode_json);
sub new {
my $class = shift;
my ($client, $args) = @_;
$class = ref $clas
', $_[1]) }
sub data { $#_ == 0 ? $_[0]->SUPER::data : $_[0]->_set_key('data', encode_json($_[1])) }
sub klass { $#_ == 0 ? $_[0]->SUPER::klass : $_[0]->_set_key('klass', $_[1]) }
ueues;
=head1 NAME
Qless::Queues
=cut
use strict; use warnings;
use Qless::Queue;
use JSON::XS qw(decode_json);
use Time::HiRes qw();
use Qless::Utils qw(fix_empty_array);
sub new {
my $class = s
;
$self->{'client'} = $client;
$self;
}
sub counts {
my ($self) = @_;
my $results = decode_json($self->{'client'}->_queues([], Time::HiRes::time));
$results = fix_empty_array($results);
retur
:Controller';
use Mojo::JSON;
use Rex::Endpoint::HTTP::Interface::Exec;
# This action will render a template
sub index {
my $self = shift;
my $ref = $self->req->json;
my $cmd = $ref->{exe
};
if($@) {
return $self->render_json({ok => Mojo::JSON->false, output => "$@", retval => 1});
}
$self->render_json({ok => Mojo::JSON->true, output => $out, retval => $?});
}
1;
tocol
=head1 DESCRIPTION
The protocol used by the KGB colaboration service is based on JSON-RPC
(L<http://json-rpc.org/>).
KGB service helps collaboration by relaying notifications about commits in
n a SHA1 hash (in
hexadecimal notation) calculated over the shared secret, the project ID and the
JSON-encoded message.
Upon receiving the HTTP request the server calculates the hash using the
suppli
and problems with the JSON data use HTTP code C<400>.
The error text is in the reason phrase of the HTTP status line (see RFC 2616,
section 6.1).
=head3 Errors reported on JSON-RPC level
After succ
we can do the work associated with it!
$job->process();
The job data must be serializable to JSON, and it is recommended that you use a hash for it. See below for a list of the supported job opti
c API
use strict;
use warnings;
use Moo 1;
use REST::Client;
use MIME::Base64;
use JSON qw(encode_json decode_json);
use WebService::Shutterstock::Lightbox;
use WebService::Shutterstock::Client;
use
w( error => "missing 'password' param for auth call");
}
$self->client->POST(
'/auth/customer.json',
{
username => $args{username},
password => $args{password}
}
);
my $auth_info = $se
me}: $auth_info"
);
}
}
sub categories {
my $self = shift;
$self->client->GET('/categories.json');
return $self->client->process_response;
}
sub search {
my $self = shift;
my %args = @_;
mplates;
use Mojo::ByteStream qw/b/;
use Data::Dumper;
use Clustericious::Log;
use Mojo::URL;
use JSON::XS;
use Scalar::Util qw/weaken/;
use Mojo::Base 'Mojolicious';
use File::HomeDir ();
use Cluste
HomeDir->my_home . "/etc", "/util/etc", "/etc" );
{
no warnings 'redefine';
sub Math::BigInt::TO_JSON {
my $val = shift;
my $copy = "$val";
my $i = 0 + $copy;
return $i;
}
}
=head2 $
se qw/ Str ArrayRef /;
use Scalar::Util qw/ weaken /;
use namespace::clean -except => 'meta';
use JSON;
use AnyMQ;
use AnyEvent;
use PocketIO;
use Twiggy::Server;
use Plack::Builder;
use Data::Section
age' => sub {
my $class = shift;
$class->send( to_json($self->_messages) );
$self->_clear_messages;
}
$server->register_service($app);
}
sub consume {
my ( $self, $msg ) = @_;
$msg = from_json($msg) unless ref($msg);
$self->anymq->publish({ msg => $msg });
}
# Preloaded methods go he
ackage Qless::Queue;
=head1 NAME
Qless:Queue
=cut
use strict; use warnings;
use JSON::XS qw(decode_json encode_json);
use Qless::Jobs;
use Qless::Job;
use Time::HiRes qw();
=head1 METHODS
=head2
e'}, $self->{'client'});
}
=head2 C<counts>
=cut
sub counts {
my ($self) = @_;
return decode_json($self->{'client'}->_queues([], Time::HiRes::time, $self->{'name'}));
}
=head2 C<heartbeat>
=cut
_json($data),
Time::HiRes::time,
$args{'delay'} || 0,
'priority', $args{'priority'} || 0,
'tags', encode_json($args{'tags'} || []),
'retries', $args{'retries'} || 5,
'depends', encode_json
package Rex::Endpoint::HTTP::Base;
use Mojo::Base 'Mojolicious::Controller';
use Mojo::JSON;
# This action will render a template
sub index {
my $self = shift;
$self->render_text("Rex::Endpoi
ocalhost:1234' }];
YAML:
create_config_ok 'Foo', <<EOF;
---
url: http://localhost:1234
EOF
JSON:
create_config_ok 'Foo', <<EOF;
{"url":"http://localhost:1234"}
EOF
In addition to being a t
erializer-CompressJSON
#
# This software is copyright (c) 2012 by Weborama. No
# license is granted to other entities.
#
package DBIx::Class::InflateColumn::Serializer::CompressJSON;
{
$DBIx::Class
n::Serializer::CompressJSON::VERSION = '0.004';
}
# ABSTRACT: DBIx::Class::InflateColumn::Serializer::CompressJSON - JSON compressed Inflator
use strict;
use warnings;
use JSON qw//;
use Compress::Z
press( JSON::to_json(shift) );
}
elsif ( $compress_method eq 'mysql' ) {
my $json = JSON::to_json(shift);
$b = pack( 'L', length($json) ) . compress($json);
Merge qw/merge/;
use Data::Dumper;
use Carp qw( croak );
use base qw( Exporter );
use JSON::MaybeXS qw( encode_json );
use Clustericious::Config;
# ABSTRACT: Helpers for clustericious config files.
o
r @mergeStack;
our @EXPORT = qw( extends_config get_password home file dir hostname hostname_full json yaml address public_address interface );
sub extends_config
{
my($name, @args) = @_;
push @
;
}
sub hostname_full
{
require Sys::Hostname;
Sys::Hostname::hostname();
}
sub json ($)
{
encode_json($_[0]);
}
sub yaml ($)
{
require YAML::XS;
local $YAML::UseHeader = 0;
my $str
s : given the plural of a table, look up the name of the class
The route that is created turns a JSON structure which is POSTed into
parameters for Rose::DB::Object::Manager::get_objects.
Additional
turns that
resultset to the client.
=cut
package Clustericious::RouteBuilder::Search;
use Mojo::JSON;
use Clustericious::Log;
use List::MoreUtils qw/uniq/;
use Data::Dumper;
use strict;
use Sub::Ex
helper called 'parse_autodata' that handles incoming data by
Content-Type.
Supports application/json, text/x-yaml and
application/x-www-form-urlencoded (in-bound only).
When parse_autodata is calle
Accept header, the Content-Type header, or the default. (By
default, the default is application/json, but you can override that
too).
=head1 TODO
more documentation
handle XML with schemas
handl
';
use JSON::XS;
use YAML::XS qw/Dump Load/;
use Clustericious::Log;
my $default_decode = 'application/x-www-form-urlencoded';
my $default_encode = 'application/json';
my $json_encoder = JSON::XS->