Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongo-php-library
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
mongo-php-library
Commits
5042a2fa
Unverified
Commit
5042a2fa
authored
Aug 21, 2019
by
Andreas Braun
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #662
parents
e4213652
f86f2207
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
296 additions
and
5 deletions
+296
-5
ChangeStream.php
src/ChangeStream.php
+1
-1
Watch.php
src/Operation/Watch.php
+6
-3
WatchFunctionalTest.php
tests/Operation/WatchFunctionalTest.php
+289
-1
No files found.
src/ChangeStream.php
View file @
5042a2fa
...
@@ -220,7 +220,7 @@ class ChangeStream implements Iterator
...
@@ -220,7 +220,7 @@ class ChangeStream implements Iterator
*/
*/
private
function
resume
()
private
function
resume
()
{
{
$this
->
iterator
=
call_user_func
(
$this
->
resumeCallable
,
$this
->
getResumeToken
());
$this
->
iterator
=
call_user_func
(
$this
->
resumeCallable
,
$this
->
getResumeToken
()
,
$this
->
hasAdvanced
);
$this
->
iterator
->
rewind
();
$this
->
iterator
->
rewind
();
$this
->
onIteration
(
$this
->
hasAdvanced
);
$this
->
onIteration
(
$this
->
hasAdvanced
);
...
...
src/Operation/Watch.php
View file @
5042a2fa
...
@@ -250,7 +250,7 @@ class Watch implements Executable, /* @internal */ CommandSubscriber
...
@@ -250,7 +250,7 @@ class Watch implements Executable, /* @internal */ CommandSubscriber
{
{
return
new
ChangeStream
(
return
new
ChangeStream
(
$this
->
createChangeStreamIterator
(
$server
),
$this
->
createChangeStreamIterator
(
$server
),
function
(
$resumeToken
)
{
return
$this
->
resume
(
$resumeToken
);
}
function
(
$resumeToken
,
$hasAdvanced
)
{
return
$this
->
resume
(
$resumeToken
,
$hasAdvanced
);
}
);
);
}
}
...
@@ -333,10 +333,11 @@ class Watch implements Executable, /* @internal */ CommandSubscriber
...
@@ -333,10 +333,11 @@ class Watch implements Executable, /* @internal */ CommandSubscriber
*
*
* @see https://github.com/mongodb/specifications/blob/master/source/change-streams/change-streams.rst#resume-process
* @see https://github.com/mongodb/specifications/blob/master/source/change-streams/change-streams.rst#resume-process
* @param array|object|null $resumeToken
* @param array|object|null $resumeToken
* @param bool $hasAdvanced
* @return ChangeStreamIterator
* @return ChangeStreamIterator
* @throws InvalidArgumentException
* @throws InvalidArgumentException
*/
*/
private
function
resume
(
$resumeToken
=
null
)
private
function
resume
(
$resumeToken
=
null
,
$hasAdvanced
=
false
)
{
{
if
(
isset
(
$resumeToken
)
&&
!
is_array
(
$resumeToken
)
&&
!
is_object
(
$resumeToken
))
{
if
(
isset
(
$resumeToken
)
&&
!
is_array
(
$resumeToken
)
&&
!
is_object
(
$resumeToken
))
{
throw
InvalidArgumentException
::
invalidType
(
'$resumeToken'
,
$resumeToken
,
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'$resumeToken'
,
$resumeToken
,
'array or object'
);
...
@@ -347,12 +348,14 @@ class Watch implements Executable, /* @internal */ CommandSubscriber
...
@@ -347,12 +348,14 @@ class Watch implements Executable, /* @internal */ CommandSubscriber
// Select a new server using the original read preference
// Select a new server using the original read preference
$server
=
$this
->
manager
->
selectServer
(
$this
->
aggregateOptions
[
'readPreference'
]);
$server
=
$this
->
manager
->
selectServer
(
$this
->
aggregateOptions
[
'readPreference'
]);
$resumeOption
=
isset
(
$this
->
changeStreamOptions
[
'startAfter'
])
&&
!
$hasAdvanced
?
'startAfter'
:
'resumeAfter'
;
unset
(
$this
->
changeStreamOptions
[
'resumeAfter'
]);
unset
(
$this
->
changeStreamOptions
[
'resumeAfter'
]);
unset
(
$this
->
changeStreamOptions
[
'startAfter'
]);
unset
(
$this
->
changeStreamOptions
[
'startAfter'
]);
unset
(
$this
->
changeStreamOptions
[
'startAtOperationTime'
]);
unset
(
$this
->
changeStreamOptions
[
'startAtOperationTime'
]);
if
(
$resumeToken
!==
null
)
{
if
(
$resumeToken
!==
null
)
{
$this
->
changeStreamOptions
[
'resumeAfter'
]
=
$resumeToken
;
$this
->
changeStreamOptions
[
$resumeOption
]
=
$resumeToken
;
}
}
if
(
$resumeToken
===
null
&&
$this
->
operationTime
!==
null
)
{
if
(
$resumeToken
===
null
&&
$this
->
operationTime
!==
null
)
{
...
...
tests/Operation/WatchFunctionalTest.php
View file @
5042a2fa
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment