The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Disbatch::Web::Tasks - Disbatch::Web routes for deprecated task search and creation.

VERSION

version 4.103

DEPRECATION NOTICE

This is deprecated as of Disbatch 4.2 and may be removed in Disbatch 4.4.

NOTE

These routes were formerly in Disbatch::Web, but moved here. They are not loaded by default.

SUBROUTINES

init($disbatch, $args)

Parameters: a Disbatch::Web object ($args is ignored).

Sets package global $disbatch.

Returns nothing.

deserialize_oid($object)

Parameters: decoded JSON filter for the search (or a sub-value from it)

If the object has the field $oid, it is turned into a MongoDB::OID object.

Returns the modified object.

search()

Parameters: none (but parses request parameters, see POST /tasks/search below)

Performs task search.

Returns result as JSON, setting HTTP status to 400 on error.

JSON ROUTES

POST /tasks/search

Parameters: { "filter": filter, "options": options, "count": count, "terse": terse }

All parameters are optional.

filter is a filter expression (query) object.

options is an object of desired options to MongoDB::Collection#find.

If not set, options.limit will be 100. This will fail if you try to set it above 100.

count is a boolean. Instead of an array of task documents, the count of task documents matching the query will be returned.

terse is a boolean. If true, the the GridFS id or "[terse mode]" will be returned for stdout and stderr of each document. If false, the full content of stdout and stderr will be returned. Default is true.

Returns: Array of task Objects or { "count": $count } on success; { "error": "filter and options must be name/value objects" }, { "error": "limit cannot exceed 100" }, or { "error": "Bad OID passed: $error" } on input error; or { "error": "$error" } on count or search error.

Sets HTTP status to 400 on error.

Note: replaces /search-tasks-json

POST /tasks/:queue

URL: :queue is the _id if it matches /\A[0-9a-f]{24}\z/, or name if it does not.

Parameters: an array of task params objects

Returns: { ref $res: Object } on success; { "error": "params must be a JSON array of task params" } or { "error": "queue not found" } on input error; or { ref $res: Object, "error": "Unknown error" } on MongoDB error.

Sets HTTP status to 400 on error.

Note: replaces /queue-create-tasks-json

POST /tasks/:queue/:collection

URL: :queue is the _id if it matches /\A[0-9a-f]{24}\z/, or name if it does not. :collection is a MongoDB collection name.

Parameters: { "filter": filter, "params": params }

filter is a filter expression (query) object for the :collection collection.

params is an object of task params. To insert a document value from a query into the params, prefix the desired key name with document. as a value.

Returns: { ref $res: Object } on success; { "error": "filter and params required and must be name/value objects" } or { "error": "queue not found" } on input error; { "error": "Could not iterate on collection $collection: $error" } on query error, or { ref $res: Object, "error": "Unknown error" } on MongoDB error.

Sets HTTP status to 400 on error.

Note: replaces /queue-create-tasks-from-query-json

SEE ALSO

Disbatch::Web

AUTHORS

Ashley Willis <awillis@synacor.com>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2016, 2019 by Ashley Willis.

This is free software, licensed under:

  The Apache License, Version 2.0, January 2004