The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

JobCenter::Client::Mojo - JobCenter JSON-RPC 2.0 Api client using Mojo.

SYNOPSIS

  use JobCenter::Client::Mojo;

   my $client = JobCenter::Client::Mojo->new(
     address => ...
     port => ...
     who => ...
     token => ...
   );

   my ($job_id, $outargs) = $client->call(
     wfname => 'test',
     inargs => { test => 'test' },
   );

DESCRIPTION

JobCenter::Client::Mojo is a class to build a client to connect to the JSON-RPC 2.0 Api of the JobCenter workflow engine. The client can be used to create and inspect jobs as well as for providing 'worker' services to the JobCenter.

METHODS

new

$client = JobCenter::Client::Mojo->new(%arguments);

Class method that returns a new JobCenter::Client::Mojo object.

Valid arguments are:

- address: address of the Api.

(default: 127.0.0.1)

- port: port of the Api

(default 6522)

- tls: connect using tls

(default false)

- who: who to authenticate as.

(required)

- method: how to authenticate.

(default: password)

- token: token to authenticate with.

(required)

- debug: when true prints debugging using Mojo::Log

(default: false)

- json: flag wether input is json or perl.

when true expects the inargs to be valid json, when false a perl hashref is expected and json encoded. (default true)

- log: Mojo::Log object to use

(per default a new Mojo::Log object is created)

- timeout: how long to wait for operations to complete

(default 60 seconds)

call

($job_id, result) = $client->call(%args);

Creates a new JobCenter job and waits for the results. Throws an error if somethings goes wrong immediately. Errors encountered during later processing are returned as a JobCenter error object.

Valid arguments are:

- wfname: name of the workflow to call (required)
- inargs: input arguments for the workflow (if any)
- vtag: version tag of the workflow to use (optional)

call_nb

$job_id = $client->call_nb(%args);

Creates a new JobCenter job and call the provided callback on completion of the job. Throws an error if somethings goes wrong immediately. Errors encountered during later processing are returned as a JobCenter error object to the callback.

Valid arguments are those for call and:

- cb: coderef to the callback to call on completion (requird)

( cb => sub { ($job_id, $outargs) = @_; ... } )

announce

Announces the capability to do an action to the Api. The provided callback will be called when there is a task to be performed. Returns an error when there was a problem announcing the action.

  my $err = $client->announce(
    actionname => '...',
    cb => sub { ... },
  );
  die "could not announce $actionname?: $err" if $err;

See jcworker for an example.

Valid arguments are:

- actionname: name of the action

(required)

- cb: callback to be called for the action

(required)

- async: if true then the callback gets passed another callback as the last argument that is to be called on completion of the task.

(default false)

- slots: the amount of tasks the worker is able to process in parallel for this action.

(default 1)

work

Starts the Mojo::IOLoop.

SEE ALSO

1 POD Error

The following errors were encountered while parsing the POD:

Around line 500:

'=item' outside of any '=over'

=over without closing =back