# # Copyright (c) 2014 NetApp, Inc., All Rights Reserved. # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @pod here package NACL::ServiceAPI::HelloWorld; use strict; use warnings; use parent qw(NACL::ServiceAPI); 1; __END__ =head1 NAME NACL::ServiceAPI::HelloWorld - Client Side to the HelloWorld Service =head1 SYNOPSIS use NACL::ServiceAPI::HelloWorld; =head1 DESCRIPTION A C is used to direct the HelloWorld Service. =head1 METHODS =head2 new This is the constructor method that finds running C services and gets prepared to talk to them. =over =item Synopsis use NACL::ServiceAPI::HelloWorld; my $api = NACL::ServiceAPI::HelloWorld->new(); =back =head2 hello_world This is a pass through to the 'hello_world' functionality in the HelloWorld service =over =item Synopsis use NACL::ServiceAPI::HelloWorld; my $api = NACL::ServiceAPI::HelloWorld->new(); print $api->hello_world(request_timeout => -1)."\n"; # or my $req_id = $api->hello_world(); print $api->request_get(id => $req_id) ."\n"; # or require NATE::Events;# qw(eventloop_drain); require NATE::Service::Constants;# qw(STATUS_READY STATUS_WAITING); my @req_ids; push(@req_ids, $api->hello_world()); push(@req_ids, $api->hello_world()); while(@req_ids) # Never Ever wait on one request when others may have already come in { my @temp = @req_ids; NATE::Events::eventloop_drain(); for my $id (@temp) { my $id = shift(@req_ids); my $status = $api->request_status(id=>$id); if($status == &NATE::Service::Constants::STATUS_READY) { print $api->request_get(id => $id) ."\n"; } elsif($status == &NATE::Service::Constants::STATUS_WAITING) { push(@req_ids, $id); # Not ready yet, put it back on the stack to try later } } } =back =head2 goodnight_moon This is a pass through to the 'goodnight_moon' functionality in the HelloWorld service. The C functionality in the service causes some artificial delay inorder to simulate a real C request. =over =item Synopsis use NACL::ServiceAPI::HelloWorld; my $api = NACL::ServiceAPI::HelloWorld->new(); print $api->goodnight_moon(seconds=>10, request_timeout => -1)."\n"; # or my $req_id = $api->goodnight_moon(seconds=>10); print $api->request_get(id => $req_id) ."\n"; # or require NATE::Events;# qw(eventloop_drain); require NATE::Service::Constants;# qw(STATUS_READY STATUS_WAITING); my @req_ids; push(@req_ids, $api->goodnight_moon(seconds=>10)); push(@req_ids, $api->hello_world()); while(@req_ids) # Never Ever wait on one request when others may have already come in { my @temp = @req_ids; NATE::Events::eventloop_drain(); for my $id (@temp) { my $id = shift(@req_ids); my $status = $api->request_status(id=>$id); if($status == &NATE::Service::Constants::STATUS_READY) { print $api->request_get(id => $id) ."\n"; } elsif($status == &NATE::Service::Constants::STATUS_WAITING) { push(@req_ids, $id); # Not ready yet, put it back on the stack to try later } } } =item Arguments =over =item C<< seconds => $seconds >> (Optional) This is the amount of seconds that the service worker will sleep before giving the return data Default: 5 =back =back =head1 SEE ALSO This is a derived class of L>. Please see the documentation for more details =head1 AUTHOR/MAINTAINER NACL Development (dl-nacl-dev@netapp.com) =cut