class FindDriver extends AbstractDriver

Properties

protected Channel|null $stopSignal from  AbstractDriver
protected bool $stopping from  AbstractDriver
protected list<string> $referenceFiles
protected int $activeReferenceIndex
protected array<string, true> $inventory
protected bool $hasCompleteInventory

Methods

__construct(Option $option, StdoutLoggerInterface $logger)

No description

bool
isDarwin()

Determine if the current OS is macOS.

void
stop()

Stop the active watch lifecycle.

bool
isStopping()

Determine whether the driver has been stopped.

void
watchAtInterval(float $seconds, callable $scan)

Run a polling scan until the driver is stopped.

array
resolveTargets(array $watchPaths)

Resolve configured watch paths to absolute targets.

array
groupWatchPathsByTarget(array $watchPaths)

Group watch paths by their resolved target.

array
existingTargets(array $targets)

Filter targets that currently exist.

array
exec(string $command)

Execute a shell command using Swoole's coroutine-aware exec.

string
shellArguments(array $arguments)

Escape a list of arguments for interpolation into a shell command.

void
watch(Channel $channel)

Watch for file changes using find -newer.

array
scan()

Scan watched targets for changed and currently live files.

void
logDegradedCycle(int $failureCode, bool $changedComplete, bool $inventoryComplete)

Report the guarantees affected by a degraded scan cycle.

array
find(array $targets, bool $recursive, bool $changed)

Run one changed-file or inventory traversal.

array
matchingFiles(string $output)

Parse complete matching paths from NUL-delimited command output.

array
reconcileInventory(array $changedFiles, array $currentInventory, bool $inventoryComplete)

Reconcile changed files with the latest complete or partial inventory.

void
ensureReferenceFiles()

Ensure this lifecycle owns two unique reference files.

string
createReferenceFile()

Create a unique reference file.

void
updateReferenceFile(string $path)

Update a reference file to the current filesystem timestamp.

string
activeReferenceFile()

Return the reference that bounds the current changed traversal.

string
inactiveReferenceFile()

Return the reference that will bound the next changed traversal.

void
rotateReferenceFiles()

Make the pre-recorded next cutoff authoritative.

void
removeReferenceFiles()

Remove every reference file owned by this lifecycle.

Details

at line 26
__construct(Option $option, StdoutLoggerInterface $logger)

No description

Parameters

Option $option
StdoutLoggerInterface $logger

in AbstractDriver at line 26
bool isDarwin()

Determine if the current OS is macOS.

Return Value

bool

in AbstractDriver at line 34
void stop()

Stop the active watch lifecycle.

Return Value

void

in AbstractDriver at line 51
protected bool isStopping()

Determine whether the driver has been stopped.

The state may change while hooked I/O yields to another coroutine.

Return Value

bool

in AbstractDriver at line 59
protected void watchAtInterval(float $seconds, callable $scan)

Run a polling scan until the driver is stopped.

Parameters

float $seconds
callable $scan

Return Value

void

in AbstractDriver at line 96
protected array resolveTargets(array $watchPaths)

Resolve configured watch paths to absolute targets.

Parameters

array $watchPaths

Return Value

array

in AbstractDriver at line 116
protected array groupWatchPathsByTarget(array $watchPaths)

Group watch paths by their resolved target.

Parameters

array $watchPaths

Return Value

array

in AbstractDriver at line 137
protected array existingTargets(array $targets)

Filter targets that currently exist.

Parameters

array $targets

Return Value

array

in AbstractDriver at line 149
protected array exec(string $command)

Execute a shell command using Swoole's coroutine-aware exec.

Every interpolated argument must be escaped before it reaches this boundary.

Parameters

string $command

Return Value

array

in AbstractDriver at line 165
protected string shellArguments(array $arguments)

Escape a list of arguments for interpolation into a shell command.

Parameters

array $arguments

Return Value

string

at line 40
void watch(Channel $channel)

Watch for file changes using find -newer.

Parameters

Channel $channel

Return Value

void

at line 98
protected array scan()

Scan watched targets for changed and currently live files.

Return Value

array

at line 148
protected void logDegradedCycle(int $failureCode, bool $changedComplete, bool $inventoryComplete)

Report the guarantees affected by a degraded scan cycle.

Parameters

int $failureCode
bool $changedComplete
bool $inventoryComplete

Return Value

void

at line 174
protected array find(array $targets, bool $recursive, bool $changed)

Run one changed-file or inventory traversal.

Parameters

array $targets
bool $recursive
bool $changed

Return Value

array

at line 196
protected array matchingFiles(string $output)

Parse complete matching paths from NUL-delimited command output.

Parameters

string $output

Return Value

array

at line 233
protected array reconcileInventory(array $changedFiles, array $currentInventory, bool $inventoryComplete)

Reconcile changed files with the latest complete or partial inventory.

Parameters

array $changedFiles
array $currentInventory
bool $inventoryComplete

Return Value

array

at line 265
protected void ensureReferenceFiles()

Ensure this lifecycle owns two unique reference files.

Return Value

void

at line 281
protected string createReferenceFile()

Create a unique reference file.

Return Value

string

at line 295
protected void updateReferenceFile(string $path)

Update a reference file to the current filesystem timestamp.

Parameters

string $path

Return Value

void

at line 305
protected string activeReferenceFile()

Return the reference that bounds the current changed traversal.

Return Value

string

at line 313
protected string inactiveReferenceFile()

Return the reference that will bound the next changed traversal.

Return Value

string

at line 321
protected void rotateReferenceFiles()

Make the pre-recorded next cutoff authoritative.

Return Value

void

at line 329
protected void removeReferenceFiles()

Remove every reference file owned by this lifecycle.

Return Value

void