apiRead. Reader

The reads of one Task run that has to tell a failed load from an empty one (QuickPlayTask, GetShuffleItemsTask, SearchTask). It counts the reads that did not answer, so an empty result is not told as "nothing here", and logs why each one failed at warn: the viewer's message says only that it failed, so the log is where the cause lives (timeout, HTTP status, unreadable reply). A Task builds one per run, with its own logger.

Constructor

new Reader(logger, label) → {apiRead.Reader}

Parameters:
NameTypeDescription
loggerobject

the Task's log.Logger

labelstring

what the reads are for, named in the warning

Properties
NameTypeDescription
anyFailedboolean

A read did not answer, or could not be sent.

sentCountinteger

How many reads were asked for, and how many of them did not answer.

failedCountinteger
Returns:
Type: 
apiRead.Reader

Methods

json(req, requestId) → {dynamic}

The parsed body of req, or invalid when the read did not answer. Only a failed read returns invalid: an answered empty result is a body, so a caller can tell the two apart and stop rather than fall back to a guess.

Parameters:
NameTypeDescription
reqdynamic

the request AA, or invalid when it could not be built

requestIdstring

the pool request id, also the log's label

Returns:

the parsed body, or invalid

Type: 
dynamic