Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

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

(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.

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

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