table => 'session',
id_as => 'session_name',
content_as => 'json_data', # optional but recommended
expire_as => 'expires', # optional, u
canonize_path
check_path
data_fh
decode_json
encode_b64 decode_b64
encode_json
extra_missing
http_date
JSON
make_getters
maybe_list
path_prefixes
r
ex
run_all
run_all_nodie
supported_methods
);
our @CARP_NOT;
# use JSON::MaybeXS; # not now, see JSON() below
# Alphabetic order, please
=head2 caller_info()
Returns first caller(n) th
};
=head2 JSON()
Because JSON::MaybeXS is not available on all systems, try to load it
or emulate it.
=head2 encode_json
=head2 decode_json
These two are reexported from whatever JSON module we
iew::JS;
use strict;
use warnings;
our $VERSION = '0.2901';
=head1 NAME
MVC::Neaf::View::JS - JSON-based view for Not Even A Framework.
=head1 SYNOPSIS
See L<MVC::Neaf>.
use MVC::Neaf;
he default as of 0.20
-jsonp => 'my.jsonp.callback', # this is optional
}
};
Will result in your application returning raw data in JSON/JSONP format
instead or rendering a tem
=head1 METHODS
=cut
use Carp;
use MVC::Neaf::Util qw(JSON);
use parent qw(MVC::Neaf::View);
my $js_id_re = qr/[A-Z_a-z][A-Z_a-z\d]*/;
my $jsonp_re = qr/^$js_id_re(?:\.$js_id_re)*$/;
=head2 new( %
ractTable';
use CallBackery::Translate qw(trm);
use CallBackery::Exception qw(mkerror);
use Mojo::JSON qw(true false);
=head1 NAME
<%= ${class} %>::GuiPlugin::Song - Song Table
=head1 SYNOPSIS
us
MVC::Neaf::X::Session>.
It will store session data inside a single directory.
The file format is JSON but MAY change in the future.
Uses flock() to avoid collisions.
If session_ttl was specified, o
use Fcntl qw(:flock :seek);
use URI::Escape qw(uri_escape);
use MVC::Neaf::Util qw(JSON encode_json decode_json);
use parent qw(MVC::Neaf::X::Session);
=head2 new( %options )
Constructor. %option
Currently JSON is used.
=cut
sub encode_content {
my ($self, $data) = @_;
return encode_json( $data );
};
sub decode_content {
my ($self, $raw) = @_;
return decode_json( $raw );
sub fetch { ... };
1;
=head1 METHODS
=cut
use Carp;
use MVC::Neaf::Util qw(encode_json decode_json);
use parent qw(MVC::Neaf::X::Session);
=head2 new( %options )
%options may include:
=ov
ode_json( $data ) };
carp "Failed to encode session data: $@"
if $@;
return $str;
};
=head2 decode
=cut
sub decode {
my ($self, $data) = @_;
my $obj = eval { decode_json( $d
r-list/index.html>.
=head3 JSON to HTML
This script converts arbitrary JSON to HTML:
use utf8;
use JSON::Parse 'parse_json';
use HTML::Make;
my $json =<<EOF;
{"words":[{"j_
ンプリムント"}]}
EOF
my $p = parse_json ($json);
my $html = json_to_html ($p);
print $html->text ();
exit;
sub json_to_html
{
my ($input) = @_;
m
for my $k (@$input) {
my $li = $element->push ('li');
$li->push (json_to_html ($k));
}
}
elsif (ref $input eq 'HASH') {
$elemen
=> 7;
use constant LOG_DEBUG => 8;
use constant LOG_TRACE => 9;
use JSON::XS;
use Exporter 'import';
use Time::HiRes;
my $JSON;
our @EXPORT_OK = qw(
LOG_FATAL
LOG_ALERT
LOG_CRIT
L
>{is_connected};
# JSON-RPC notification
$JSON = JSON::XS->new->utf8->allow_blessed->convert_blessed unless defined $JSON;
my $json = $JSON->encode({
jsonrpc => '2.0',
m
|;
$bus->publish(
topic => "log/$level/$service",
payload => \$json,
);
};
if ($@) {
my $msg = $@; chomp($msg);
print STDERR "[$tsta
package Beekeeper::JSONRPC::Notification;
use strict;
use warnings;
our $VERSION = '0.10';
sub new {
my $class = shift;
bless {
jsonrpc => '2.0',
method => undef,
::JSONRPC::Notification - Representation of a JSON-RPC notification
=head1 VERSION
Version 0.09
=head1 DESCRIPTION
Objects of this class represent a JSON-RPC notification (see L<http://www.jsonr
y. In order to add Router workers to a pool
these must be declared into config file C<pool.config.json>.
=head1 METHODS
=head3 bind_remote_session ( address => $address )
Make authorization data pe
s> and C<on_error> must be coderefs and will receive respectively
L<Beekeeper::JSONRPC::Response> and L<Beekeeper::JSONRPC::Error> objects as arguments.
=head3 unbind_remote_session_async ( on_succe
10';
use Beekeeper::Client ':worker';
use Beekeeper::Logger ':log_levels';
use Beekeeper::JSONRPC;
use JSON::XS;
use Time::HiRes ();
use Sys::Hostname ();
use Compress::Raw::Zlib ();
use Digest::MD5
our $REPORT_STATUS_PERIOD = 5;
our $UNSUBSCRIBE_LINGER = 2;
my %AUTH_TOKENS;
my $DEFLATE;
my $JSON;
sub new {
my ($class, %args) = @_;
# Parameters passed by WorkerPool->spawn_worker
ig => $args{'bus_config'}, # content of bus.config.json
pool_config => $args{'pool_config'}, # content of pool.config.json
pool_id => $args{'pool_id'},
bus_
keeper::JSONRPC;
use strict;
use warnings;
our $VERSION = '0.10';
use Beekeeper::JSONRPC::Request;
use Beekeeper::JSONRPC::Notification;
use Beekeeper::JSONRPC::Response;
use Beekeeper::JSONRPC::Er
Beekeeper::JSONRPC::Request->new(@_);
}
sub notification {
my $class = shift;
Beekeeper::JSONRPC::Notification->new(@_);
}
sub response {
my $class = shift;
Beekeeper::JSONRPC::Respo
{
my $class = shift;
Beekeeper::JSONRPC::Error->new(@_);
}
1;
__END__
=pod
=encoding utf8
=head1 NAME
Beekeeper::JSONRPC - Representation of JSON-RPC objects
=head1 VERSION
Version 0.
ess ($pool_cfg) {
die "Worker pool '$pool_id' is not defined into config file pool.config.json\n";
}
# Ensure that local bus is defined
my $bus_id = $pool_cfg->{'bus_id'};
un
config file bus.config.json\n";
}
# Merge pool.config.json contents
$self->{config}->{$_} = $pool_cfg->{$_} foreach (keys %$pool_cfg);
# Keep bus.config.json
$self->{bus_config}
respawns defunct ones.
=head1 CONFIGURATION
=head3 pool.config.json
Workers pools are defined into a file named C<pool.config.json>, which is searched
for into ENV C<BEEKEEPER_CONFIG_DIR>, C<~/.co
se base 'Beekeeper::Worker';
use Beekeeper::Logger ':log_levels';
use Scalar::Util 'weaken';
use JSON::XS;
my @Log_buffer;
sub authorize_request {
my ($self, $req) = @_;
return unless $se
=> sub {
# my ($payload_ref, $mqtt_properties) = @_;
$req = decode_json( ${$_[0]} );
push @Log_buffer, $req->{params};
shift @Log_buffe
ly. In order to add a LogTail worker to a
pool it must be declared into config file C<pool.config.json>:
[
{
"pool_id" : "myapp",
"bus_id" : "backend",
"workers
tension::SharedCache::Cache; # hide from PAUSE
use Beekeeper::Worker ':log';
use AnyEvent;
use JSON::XS;
use Fcntl qw(:DEFAULT :flock);
use Scalar::Util 'weaken';
use Carp;
use constant SYNC_REQUE
sh => sub {
# my ($payload_ref, $mqtt_properties) = @_;
my $entry = decode_json( ${$_[0]} );
$self->_merge($entry);
},
on_suback => sub {
ish => sub {
my ($payload_ref, $mqtt_properties) = @_;
my $dump = decode_json($$payload_ref);
$self->_merge_dump($dump);
$self->_sync_completed(1);
s.oasis-open.org/mqtt/mqtt/v5.0/mqtt-v5.0.html>).
- The RPC protocol is JSON-RPC 2.0 (see the L<specification|https://www.jsonrpc.org/specification>).
- There is no message persistence in the broker
eekeeper> and
then C</etc/beekeeper>. File format is relaxed JSON, which allows comments and trailing commas.
The file C<pool.config.json> defines all worker pools running on a host, specifying whic
ers" : {
"MyApp::Worker" : { "worker_count" : 4 },
},
}]
The file C<bus.config.json> defines all logical buses used by the application, specifying the connection
parameters to the b
elf->{users} = {};
my $config = Beekeeper::Config->read_config_file( 'toybroker.config.json' );
# Start a default listener if no config found
$config = [ {} ] unless defined $confi
roker>
option set to a true value in its config file C<pool.config.json>.
ToyBroker is configured from file C<toybroker.config.json>, which is looked for
in ENV C<BEEKEEPER_CONFIG_DIR>, C<~/.config
VERSION = '0.10';
use Beekeeper::AnyEvent;
use Beekeeper::MQTT;
use Beekeeper::JSONRPC;
use Beekeeper::Config;
use JSON::XS;
use Compress::Raw::Zlib ();
use Digest::MD5 'md5_base64';
use Carp;
use
bus_id => $bus_id );
croak "Bus '$bus_id' is not defined into config file bus.config.json" unless $config;
%args = ( %$config, %args );
}
else {
my
fault} } keys %$config;
croak "No default bus defined into config file bus.config.json" unless $default;
$bus_id = $config->{$default}->{'bus_id'};
%arg
ool Str Num Int HashRef InstanceOf);
use WebService::Rackspace::CloudFiles::Object::Iterator;
use JSON::Any;
use Carp qw(confess);
has 'cloudfiles' =>
( is => 'ro', isa => InstanceOf['WebService
$cdn_enabled = $response->header('X-CDN-Enabled');
$self->cdn_enabled(ref $cdn_enabled eq ref JSON::Any->true ? 1 : 0 );
$self->ttl( $response->header('X-TTL') );
$self->log_retention( $re
);
$url->query_param( 'prefix', $prefix );
$url->query_param( 'format', 'json' );
my $request = HTTP::Request->new( 'GET', $url,
[ 'X-Auth-Token' =
package Beekeeper::JSONRPC::Request;
use strict;
use warnings;
our $VERSION = '0.10';
sub new {
my $class = shift;
bless {
jsonrpc => '2.0',
method => undef,
param
d_response(@_);
}
1;
__END__
=pod
=encoding utf8
=head1 NAME
Beekeeper::JSONRPC::Request - Representation of a JSON-RPC request
=head1 VERSION
Version 0.09
=head1 SYNOPSIS
my $client =
print $req->result;
=head1 DESCRIPTION
Objects of this class represent a JSON-RPC request (see L<http://www.jsonrpc.org/specification>).
The method L<Beekeeper::Client::call_remote_async> ret