App-Context

 view release on metacpan or  search on metacpan

lib/App/CallDispatcher.pm  view on Meta::CPAN

$VERSION = (q$Revision: 6783 $ =~ /(\d[\d\.]*)/)[0];  # VERSION numbers generated by svn

use App;
use App::Service;
@ISA = ( "App::Service" );

use strict;

=head1 NAME

App::CallDispatcher - synchronous (potentially remote) call_dispatcher invocation

=head1 SYNOPSIS

    use App;

    $context = App->context();
    $call_dispatcher = $context->service("CallDispatcher");  # or ...
    $call_dispatcher = $context->call_dispatcher();

    $call_dispatcher->call($request, $response);
    $response = $call_dispatcher->call($request);
    $response = $call_dispatcher->call(%named);

=head1 DESCRIPTION

A CallDispatcher service is a means by which a function call (perhaps remote)
may be made synchronously.

=cut

#############################################################################
# CLASS GROUP
#############################################################################

=head1 Class Group: CallDispatcher

The following classes might be a part of the CallDispatcher Class Group.

lib/App/CallDispatcher.pm  view on Meta::CPAN


=cut

#############################################################################
# CLASS
#############################################################################

=head1 Class: App::CallDispatcher

A CallDispatcher service is a means by which a function call (perhaps remote)
may be made synchronously or asynchronously.

 * Throws: App::Exception::CallDispatcher
 * Since:  0.01

=head2 Class Design

...

=cut

lib/App/CallDispatcher/HTTPSimple.pm  view on Meta::CPAN

$VERSION = (q$Revision: 6783 $ =~ /(\d[\d\.]*)/)[0];  # VERSION numbers generated by svn

use App;
use App::Service;
@ISA = ( "App::Service" );

use strict;

=head1 NAME

App::CallDispatcher::HTTPSimple - synchronous rpc using simple HTTP protocol

=head1 SYNOPSIS

    use App;

    $context = App->context();
    $call_dispatcher = $context->service("CallDispatcher");  # or ...
    $call_dispatcher = $context->call_dispatcher();

    @returnvals = $call_dispatcher->call($service, $name, $method, $args);

=head1 DESCRIPTION

A CallDispatcher service facilitates synchronous remote procedure calls.
The HTTPSimple does this by formatting a simple HTTP request using GET
or POST and parsing the results using a serializer.

=cut

#############################################################################
# CLASS
#############################################################################

=head1 Class: App::CallDispatcher::HTTPSimple

A CallDispatcher service facilitates synchronous remote procedure calls.
The HTTPSimple does this by formatting a simple HTTP request using GET
or POST and parsing the results using a serializer.

 * Throws: App::Exception::CallDispatcher
 * Since:  0.01

=cut

#############################################################################
# PUBLIC METHODS

lib/App/Context.pm  view on Meta::CPAN

        }
        elsif ($#results == 0) {
            return($results[0]);
        }
        else {
            return(\@results);
        }
    }
}

# NOTE: The baseline context implements the API for asynchronous events
#       in a simplistic, sequential way.
#       It merely sends the event, then sends the callback event.
#       See App::Context::Server for a context that spawns processes which
#       execute the event.  When the process exits, the callback_event is fired.
#       See App::Context::Cluster for a context that sends a message to an
#       available cluster node for executing.  When the node reports back that
#       it has completed the task, the callback_event is fired.

sub send_async_event {
    &App::sub_entry if ($App::trace);

lib/App/Context.pm  view on Meta::CPAN

    * Signature: $self->wait_for_event($event_token)
    * Param:     $event_token     string
    * Return:    void
    * Throws:    App::Exception
    * Since:     0.01

    Sample Usage: 

    $self->wait_for_event($event_token);

The wait_for_event() method is called when an asynchronous event has been
sent and no more processing can be completed before it is done.

=cut

sub wait_for_event {
    &App::sub_entry if ($App::trace);
    my ($self, $event_token) = @_;
    &App::sub_exit() if ($App::trace);
}

lib/App/Context/ClusterNode.pm  view on Meta::CPAN

}

sub dispatch_events_end {
    &App::sub_entry if ($App::trace);
    my ($self) = @_;
    $self->log({level=>2},"Stopping Cluster Node\n");
    my $controller_host = $self->{controller_host};
    my $controller_port = $self->{controller_port};
    my $node_host       = $self->{host};
    my $node_port       = $self->{port};
    # We need to close the listen socket before we do a synchronous connection to the controller
    # in order to avoid deadlock.
    $self->close_listen_socket();
    # This message needs to be synchronous, otherwise the parent will kill the subprocess during shutdown.
    $self->send_message($controller_host, $controller_port, "NODE-DOWN:$node_host:$node_port");
    &App::sub_exit() if ($App::trace);
}

sub send_node_status {
    &App::sub_entry if ($App::trace);
    my ($self) = @_;
    my $controller_host = $self->{controller_host};
    my $controller_port = $self->{controller_port};
    my $node_host       = $self->{host};

lib/App/Context/POE/Server.pm  view on Meta::CPAN

    * Signature: $self->wait_for_event($event_token)
    * Param:     $event_token     string
    * Return:    void
    * Throws:    App::Exception
    * Since:     0.01

    Sample Usage: 

    $self->wait_for_event($event_token);

The wait_for_event() method is called when an asynchronous event has been
sent and no more processing can be completed before it is done.

=cut

sub wait_for_event {
    &App::sub_entry if ($App::trace);
    my ($self, $event_token) = @_;
    &App::sub_exit() if ($App::trace);
}

lib/App/Context/Server.pm  view on Meta::CPAN

    * Signature: $self->wait_for_event($event_token)
    * Param:     $event_token     string
    * Return:    void
    * Throws:    App::Exception
    * Since:     0.01

    Sample Usage: 

    $self->wait_for_event($event_token);

The wait_for_event() method is called when an asynchronous event has been
sent and no more processing can be completed before it is done.

=cut

sub wait_for_event {
    &App::sub_entry if ($App::trace);
    my ($self, $event_token) = @_;
    &App::sub_exit() if ($App::trace);
}

lib/App/MessageDispatcher.pm  view on Meta::CPAN

    $message = $messaging->receive(
        sender => $sender,
    );

    $message = $messaging->receive(
        ticket => $ticket,
    );

=head1 DESCRIPTION

A MessageDispatcher service is a means by which data can be sent asynchronously
(or synchronously) to a recipient and responses can be received.

Because the possibility exists for the messaging channel to be asynchronous,
code that uses a MessageDispatcher service must code for the most complicated case
(asynchronous).

=cut

#############################################################################
# CLASS GROUP
#############################################################################

=head1 Class Group: MessageDispatcher

The following classes might be a part of the MessageDispatcher Class Group.

lib/App/MessageDispatcher.pm  view on Meta::CPAN

=back

=cut

#############################################################################
# CLASS
#############################################################################

=head1 Class: App::MessageDispatcher

A MessageDispatcher service is a means by which data can be sent synchronously
or asynchronously to a recipient and responses can be received.

 * Throws: App::Exception::MessageDispatcher
 * Since:  0.01

=head2 Class Design

...

=cut

lib/App/ResourceLocker.pm  view on Meta::CPAN


=cut

#############################################################################
# CLASS
#############################################################################

=head1 Class: App::ResourceLocker

A ResourceLocker service represents a collection of "advisory" (or "cooperative")
resource locks.  These can be used to synchronize access to and modification
of shared resources such as are stored in a SharedDatastore.

 * Throws: App::Exception::ResourceLocker
 * Since:  0.01

=cut

#############################################################################
# CONSTRUCTOR METHODS
#############################################################################

lib/App/ResourceLocker/IPCLocker.pm  view on Meta::CPAN


=cut

#############################################################################
# CLASS
#############################################################################

=head1 Class: App::ResourceLocker::IPCLocker

A ResourceLocker service represents a collection of "advisory" (or "cooperative")
resource locks.  These can be used to synchronize access to and modification
of shared resources such as are stored in a SharedDatastore.

 * Throws: App::Exception::ResourceLocker
 * Since:  0.01

The ResourceLocker may be configured with the following parameters, which govern
all locks accessed in the ResourceLocker (as per IPC::Locker).

    family      IPC (fifo) family to communicate with the lock server
                INET: use TCP/IP networking

lib/App/ResourceLocker/IPCSemaphore.pm  view on Meta::CPAN

=cut

#############################################################################
# CLASS
#############################################################################

=head1 Class: App::ResourceLocker::IPCSemaphore

A ResourceLocker service represents a collection of "advisory"
(or "cooperative") resource locks. 
These can be used to synchronize access to and modification
of shared resources such as are stored in a SharedDatastore.

 * Throws: App::Exception::ResourceLocker
 * Since:  0.01

Generally speaking, this module only works on Unix platforms, because they
support the System V semaphore API on which the IPC::Semaphore module
is built.

The ResourceLocker may be configured with the following parameters, which



( run in 0.823 second using v1.01-cache-2.11-cpan-0d8aa00de5b )