Documentation

ChangeStream
in package
implements Iterator

Iterator for a change stream.

Tags
see
Collection::watch()
see
http://docs.mongodb.org/manual/reference/command/changeStream/

Interfaces, Classes, Traits and Enums

Iterator

Table of Contents

CURSOR_NOT_FOUND  = 43
$cursorNotFound  : int
$hasAdvanced  : bool
Whether the change stream has advanced to its first result. This is used to determine whether $key should be incremented after an iteration event.
$iterator  : ChangeStreamIterator
$key  : int
$resumableErrorCodes  : array<string|int, int>
$resumeCallable  : callable
$wireVersionForResumableChangeStreamError  : int
current()  : mixed
getCursorId()  : CursorId
getResumeToken()  : array<string|int, mixed>|object|null
Returns the resume token for the iterator's current position.
key()  : mixed
next()  : void
rewind()  : void
valid()  : bool
isResumableError()  : bool
Determines if an exception is a resumable error.
onIteration()  : mixed
Perform housekeeping after an iteration event.
resume()  : void
Recreates the ChangeStreamIterator after a resumable server error.
resumeOrThrow()  : mixed
Either resumes after a resumable error or re-throws the exception.

Constants

CURSOR_NOT_FOUND

public mixed CURSOR_NOT_FOUND = 43
Tags
deprecated
1.4
todo

Remove this in 2.0 (see: PHPLIB-360)

Properties

$hasAdvanced

Whether the change stream has advanced to its first result. This is used to determine whether $key should be incremented after an iteration event.

private bool $hasAdvanced = false

$resumableErrorCodes

private static array<string|int, int> $resumableErrorCodes = [ 6, // HostUnreachable 7, // HostNotFound 89, // NetworkTimeout 91, // ShutdownInProgress 189, // PrimarySteppedDown 262, // ExceededTimeLimit 9001, // SocketException 10107, // NotPrimary 11600, // InterruptedAtShutdown 11602, // InterruptedDueToReplStateChange 13435, // NotPrimaryNoSecondaryOk 13436, // NotPrimaryOrSecondary 63, // StaleShardVersion 150, // StaleEpoch 13388, // StaleConfig 234, // RetryChangeStream 133, ]

$wireVersionForResumableChangeStreamError

private static int $wireVersionForResumableChangeStreamError = 9

Methods

getCursorId()

public getCursorId() : CursorId
Return values
CursorId

getResumeToken()

Returns the resume token for the iterator's current position.

public getResumeToken() : array<string|int, mixed>|object|null

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 values
array<string|int, mixed>|object|null

onIteration()

Perform housekeeping after an iteration event.

private onIteration(bool $incrementKey) : mixed
Parameters
$incrementKey : bool

Increment $key if there is a current result

Tags
throws
ResumeTokenException
Return values
mixed

resume()

Recreates the ChangeStreamIterator after a resumable server error.

private resume() : void
Return values
void

resumeOrThrow()

Either resumes after a resumable error or re-throws the exception.

private resumeOrThrow(RuntimeException $exception) : mixed
Parameters
$exception : RuntimeException
Tags
throws
RuntimeException
Return values
mixed

Search results