Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 311 and 401] [Versions 39 and 311]

(no description)

File Size: 305 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

ChangeStreamIterator:: (14 methods):
  __construct()
  commandFailed()
  commandStarted()
  commandSucceeded()
  current()
  getResumeToken()
  getServer()
  key()
  next()
  rewind()
  valid()
  extractResumeToken()
  isAtEndOfBatch()
  onIteration()


Class: ChangeStreamIterator  - X-Ref

ChangeStreamIterator wraps a change stream's tailable cursor.

This iterator tracks the size of each batch in order to determine when the
postBatchResumeToken is applicable. It also ensures that initial calls to
rewind() do not execute getMore commands.

__construct(Cursor $cursor, $firstBatchSize, $initialResumeToken, $postBatchResumeToken)   X-Ref

param: Cursor            $cursor
param: integer           $firstBatchSize
param: array|object|null $initialResumeToken
param: object|null       $postBatchResumeToken

commandFailed(CommandFailedEvent $event)   X-Ref
No description

commandStarted(CommandStartedEvent $event)   X-Ref
No description

commandSucceeded(CommandSucceededEvent $event)   X-Ref
No description

current()   X-Ref

return: mixed

getResumeToken()   X-Ref
Returns the resume token for the iterator's current position.

Null may be returned if no change documents have been iterated and the
server did not include a postBatchResumeToken in its aggregate or getMore
command response.

return: array|object|null

getServer()   X-Ref
Returns the server the cursor is running on.


key()   X-Ref

return: mixed

next()   X-Ref

return: void

rewind()   X-Ref

return: void

valid()   X-Ref

return: boolean

extractResumeToken($document)   X-Ref
Extracts the resume token (i.e. "_id" field) from a change document.

param: array|object $document Change document
return: array|object

isAtEndOfBatch()   X-Ref
Return whether the iterator is positioned at the end of the batch.

return: boolean

onIteration($incrementBatchPosition)   X-Ref
Perform housekeeping after an iteration event.

param: boolean $incrementBatchPosition