mongodb/mongo-php-driver — pull request #519 by bjori (2013-08-24 04:28:52+00:00)
Title: Improve Stream Notification support

When a Stream Context contains a "notification" parameter we'll send
notification_code = MONGO_STREAM_NOTIFY_TYPE_IO_INIT
message_code =
MONGO_STREAM_NOTIFY_IO_READ
MONGO_STREAM_NOTIFY_IO_WRITE
bytes_max = How much we are about to read/write total

During the read/write we'll send incremental notification per chunk
notification_code = MONGO_STREAM_NOTIFY_IO_PROGRESS
bytes_max = how much we are about to read/write total
bytes_transferred = how much we have read/written so far

Upon completion we'll send
notification_code = MONGO_STREAM_NOTIFY_IO_COMPLETED
bytes_max = how much we are about to read/write total
bytes_transferred = how much we have read/written total

We'll also send notifications for actions (CRUD/KILL/GETMORE)
notification_code = MONGO_STREAM_NOTIFY_TYPE_LOG
message = JSON serialized array containing several different keys
"server" (array): Always available
"type" (int): MONGO_NODE_xxx
"max_bson_size" (int): Maximum BSON Size
"max_message_size" (int): Maximum BSON Message Size
"request_id" (int): The request number
See below for more info about each action

message_code =
MONGO_STREAM_NOTIFY_LOG_INSERT
Additional "message" JSON keys:
"document" (array): The document being inserted
"options" (array): Insert options (WriteConcern etc..)

MONGO_STREAM_NOTIFY_LOG_QUERY
Additional "message" JSON keys:
"query" (array): Query to execute
NOTE: Massaged for mongos
"info" (array):
"request_id": Request number
"skip": numberToSkip
"limit": numberToReturn
"options": bit vector of query options (slaveOk/tailable etc..)
"cursor_id": (always 0)

MONGO_STREAM_NOTIFY_LOG_UPDATE
Additional "message" JSON keys:
"criteria": Search query
"newobj": Modified object to store
"options" (array): All options passed to the command
"info" (array):
"namespace": Document namespace to update
"flags": bit vector of update options (upsert/multi etc..)
MONGO_STREAM_NOTIFY_LOG_DELETE
Same as LOG_UPDATE, except for "newobj"

MONGO_STREAM_NOTIFY_LOG_GETMORE
"info" (array):
"request_id": Request number
"cursor_id": Cursor ID to ask for more data

MONGO_STREAM_NOTIFY_LOG_KILLCURSOR
"info" (array):
"cursor_id": Cursor ID to kill

MONGO_STREAM_NOTIFY_LOG_BATCHINSERT
"docs": array of documents to insert
"options" (array): All options passed to the command
"info" (array):
"flags": bit vector of update options (upsert/multi etc..)

In addition, all READ operations also return:
message_code=MONGO_STREAM_NOTIFY_LOG_RESPONSE_HEADER
"query": The query we got results for
"info":
send_request_id": Request number
"cursor_id": The cursor ID this query created/operates on
"recv_request_id": The Request ID
"recv_response_to": The Request ID the server is reply to
"recv_opcode": Request Type (OP_XXX)
"flag": Any previously set flags on the serverbbb
"start": Where this cursor is starting from