ChangeStream
in package
implements
Iterator
Iterator for a change stream.
Tags
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
Properties
$cursorNotFound
private
static int
$cursorNotFound
= 43
$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
$iterator
private
ChangeStreamIterator
$iterator
$key
private
int
$key
= 0
$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,
]
$resumeCallable
private
callable
$resumeCallable
$wireVersionForResumableChangeStreamError
private
static int
$wireVersionForResumableChangeStreamError
= 9
Methods
current()
public
current() : mixed
Tags
Return values
mixed —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 —key()
public
key() : mixed
Tags
Return values
mixed —next()
public
next() : void
Tags
Return values
void —rewind()
public
rewind() : void
Tags
Return values
void —valid()
public
valid() : bool
Tags
Return values
bool —isResumableError()
Determines if an exception is a resumable error.
private
isResumableError(RuntimeException $exception) : bool
Parameters
- $exception : RuntimeException
Tags
Return values
bool —onIteration()
Perform housekeeping after an iteration event.
private
onIteration(bool $incrementKey) : mixed
Parameters
- $incrementKey : bool
-
Increment $key if there is a current result
Tags
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