yxorP Documentation

EventObserver
in package
implements CommandSubscriber

EventObserver handles "observeEvents" for client entities and assertions for "expectEvents" and special operations (e.g. assertSameLsidOnLastTwoCommands).

Interfaces, Classes, Traits and Enums

CommandSubscriber

Table of Contents

$actualEvents  : array<string|int, mixed>
$clientId  : string
$context  : Context
$ignoreCommands  : array<string|int, mixed>
The configureFailPoint command (used by failPoint and targetedFailPoint operations) is always ignored.
$observeEvents  : array<string|int, mixed>
$observeSensitiveCommands  : bool
$sensitiveCommands  : array<string|int, mixed>
These commands are always considered sensitive (i.e. command and reply documents should be redacted).
$sensitiveCommandsWithSpeculativeAuthenticate  : array<string|int, mixed>
These commands are only considered sensitive when the command or reply document includes a speculativeAuthenticate field.
$supportedEvents  : array<string|int, mixed>
$unsupportedEvents  : array<string|int, mixed>
These events are defined in the specification but unsupported by PHPLIB (e.g. CMAP events).
__construct()  : mixed
assert()  : void
commandFailed()  : void
commandStarted()  : void
commandSucceeded()  : void
getLsidsOnLastTwoCommands()  : array<string|int, mixed>
start()  : void
stop()  : void
assertCommandFailedEvent()  : void
assertCommandStartedEvent()  : void
assertCommandSucceededEvent()  : void
assertEvent()  : mixed
handleEvent()  : void
isSensitiveCommand()  : bool

Properties

$actualEvents

private array<string|int, mixed> $actualEvents = []

$ignoreCommands

The configureFailPoint command (used by failPoint and targetedFailPoint operations) is always ignored.

private array<string|int, mixed> $ignoreCommands = ['configureFailPoint' => 1]

$observeEvents

private array<string|int, mixed> $observeEvents = []

$observeSensitiveCommands

private bool $observeSensitiveCommands

$sensitiveCommands

These commands are always considered sensitive (i.e. command and reply documents should be redacted).

private static array<string|int, mixed> $sensitiveCommands = ['authenticate' => 1, 'saslStart' => 1, 'saslContinue' => 1, 'getnonce' => 1, 'createUser' => 1, 'updateUser' => 1, 'copydbgetnonce' => 1, 'copydbsaslstart' => 1, 'copydb' => 1]
Tags
see
https://github.com/mongodb/specifications/blob/master/source/command-monitoring/command-monitoring.rst#security

$supportedEvents

private static array<string|int, mixed> $supportedEvents = ['commandStartedEvent' => \MongoDB\Driver\Monitoring\CommandStartedEvent::class, 'commandSucceededEvent' => \MongoDB\Driver\Monitoring\CommandSucceededEvent::class, 'commandFailedEvent' => \MongoDB\Driver\Monitoring\CommandFailedEvent::class]

$unsupportedEvents

These events are defined in the specification but unsupported by PHPLIB (e.g. CMAP events).

private static array<string|int, mixed> $unsupportedEvents = ['poolCreatedEvent' => 1, 'poolReadyEvent' => 1, 'poolClearedEvent' => 1, 'poolClosedEvent' => 1, 'connectionCreatedEvent' => 1, 'connectionReadyEvent' => 1, 'connectionClosedEvent' => 1, 'connectionCheckOutStartedEvent' => 1, 'connectionCheckOutFailedEvent' => 1, 'connectionCheckedOutEvent' => 1, 'connectionCheckedInEvent' => 1]

Methods

__construct()

public __construct(array<string|int, mixed> $observeEvents, array<string|int, mixed> $ignoreCommands, bool $observeSensitiveCommands, string $clientId, Context $context) : mixed
Parameters
$observeEvents : array<string|int, mixed>
$ignoreCommands : array<string|int, mixed>
$observeSensitiveCommands : bool
$clientId : string
$context : Context
Return values
mixed

assert()

public assert(array<string|int, mixed> $expectedEvents) : void
Parameters
$expectedEvents : array<string|int, mixed>
Return values
void

getLsidsOnLastTwoCommands()

public getLsidsOnLastTwoCommands() : array<string|int, mixed>
Return values
array<string|int, mixed>

assertCommandFailedEvent()

private assertCommandFailedEvent(CommandFailedEvent $actual, stdClass $expected, string $message) : void
Parameters
$actual : CommandFailedEvent
$expected : stdClass
$message : string
Return values
void

assertCommandStartedEvent()

private assertCommandStartedEvent(CommandStartedEvent $actual, stdClass $expected, string $message) : void
Parameters
$actual : CommandStartedEvent
$expected : stdClass
$message : string
Return values
void

assertCommandSucceededEvent()

private assertCommandSucceededEvent(CommandSucceededEvent $actual, stdClass $expected, string $message) : void
Parameters
$actual : CommandSucceededEvent
$expected : stdClass
$message : string
Return values
void

assertEvent()

private assertEvent(mixed $actual, stdClass $expected, string $message) : mixed
Parameters
$actual : mixed
$expected : stdClass
$message : string
Return values
mixed

handleEvent()

private handleEvent(CommandStartedEvent|CommandSucceededEvent|CommandFailedEvent $event) : void
Parameters
$event : CommandStartedEvent|CommandSucceededEvent|CommandFailedEvent
Return values
void

isSensitiveCommand()

private isSensitiveCommand(CommandStartedEvent|CommandSucceededEvent|CommandFailedEvent $event) : bool
Parameters
$event : CommandStartedEvent|CommandSucceededEvent|CommandFailedEvent
Return values
bool

Search results