ChangeStream
in package
implements
Iterator
Iterator for a change stream.
Tags
Table of Contents
Interfaces
- Iterator
Constants
- CURSOR_NOT_FOUND = 43
- RESUMABLE_ERROR_CODES = [ 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, ]
- WIRE_VERSION_FOR_RESUMABLE_CHANGE_STREAM_ERROR = 9
Properties
- $codec : DocumentCodec|null
- $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
- $resumeCallable : ResumeCallable|null
Methods
- current() : array<string|int, mixed>|object|null
- getCursorId() : Int64
- getResumeToken() : array<string|int, mixed>|object|null
- Returns the resume token for the iterator's current position.
- key() : int|null
- next() : void
- rewind() : void
- valid() : bool
- isResumableError() : bool
- Determines if an exception is a resumable error.
- onIteration() : void
- Perform housekeeping after an iteration event.
- resume() : void
- Recreates the ChangeStreamIterator after a resumable server error.
- resumeOrThrow() : void
- Either resumes after a resumable error or re-throws the exception.
Constants
CURSOR_NOT_FOUND
private
mixed
CURSOR_NOT_FOUND
= 43
RESUMABLE_ERROR_CODES
private
mixed
RESUMABLE_ERROR_CODES
= [
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,
]
WIRE_VERSION_FOR_RESUMABLE_CHANGE_STREAM_ERROR
private
mixed
WIRE_VERSION_FOR_RESUMABLE_CHANGE_STREAM_ERROR
= 9
Properties
$codec
private
DocumentCodec|null
$codec
= null
$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
$resumeCallable
private
ResumeCallable|null
$resumeCallable
Methods
current()
public
current() : array<string|int, mixed>|object|null
Tags
Return values
array<string|int, mixed>|object|nullgetCursorId()
public
getCursorId() : Int64
Return values
Int64getResumeToken()
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|nullkey()
public
key() : int|null
Tags
Return values
int|nullnext()
public
next() : void
Tags
rewind()
public
rewind() : void
Tags
valid()
public
valid() : bool
Tags
Return values
boolisResumableError()
Determines if an exception is a resumable error.
private
isResumableError(RuntimeException $exception) : bool
Parameters
- $exception : RuntimeException
Tags
Return values
boolonIteration()
Perform housekeeping after an iteration event.
private
onIteration(bool $incrementKey) : void
Parameters
- $incrementKey : bool
-
Increment $key if there is a current result
Tags
resume()
Recreates the ChangeStreamIterator after a resumable server error.
private
resume() : void
resumeOrThrow()
Either resumes after a resumable error or re-throws the exception.
private
resumeOrThrow(RuntimeException $exception) : void
Parameters
- $exception : RuntimeException