class DatabaseOutboxRepository

Traits

Constants

RETRY_DELAYS

Methods

void
insertDatabaseRows(ConnectionInterface $connection, string $table, array $rows)

Insert database rows without exceeding the connection's binding limit.

void
insertDatabaseRowChunk(ConnectionInterface $connection, string $table, array $rows)

Insert one database row chunk.

int
maxBindings(ConnectionInterface $connection)

Get the statement binding limit without requiring a PDO-backed custom driver.

int
secondsUntil(DateInterval|DateTimeInterface|int $delay)

Get the number of seconds until the given DateTime.

int
availableAt(DateInterval|DateTimeInterface|int|null $delay = 0)

Get the "available at" UNIX timestamp.

parseDateInterval(DateInterval|DateTimeInterface|int|null $delay)

If the given value is an interval, convert it to a DateTime instance.

int
currentTime()

Get the current system time as a UNIX timestamp.

string
runTimeForHumans(float $startTime, float|null $endTime = null)

Given a start time, format the total run time for human readability.

__construct(ConnectionResolverInterface $resolver, array $databases, string $table, int $retryAfter)

Create a repository that resolves connections only for the current operation.

array
getDatabases()

Get the configured outbox sources.

getConnection(string $database)

Resolve a configured outbox source in the current coroutine.

void
insert(ConnectionInterface $connection, array $rows)

Insert finalized rows on the connection that owns the business transaction.

array
claim(string $database, int $limit)

Claim eligible messages without retaining a database resource in the result.

array
claimOnPostgres(ConnectionInterface $connection, int $limit, int $now, int $expiresAt, string $token)

Claim a PostgreSQL batch in one statement, retaining its original eligibility.

array
claimWithSkipLocked(ConnectionInterface $connection, int $limit, int $now, int $expiresAt, string $token)

Claim rows on engines that support skipping another relay's locked rows.

array
claimWithConditionalUpdate(ConnectionInterface $connection, int $limit, int $now, int $expiresAt, string $token)

Win eligible candidates through one atomic update on engines without skip-locked support.

array
getClaimedRows(ConnectionInterface $connection, array $candidates, string $token)

Read the rows owned by this claim with their original eligibility.

int
settle(string $database, array $messages, OutboxBatchResult $result)

Settle a validated result without modifying rows claimed by a newer relay.

int
releaseFailed(ConnectionInterface $connection, string $token, array $ids, string $error)

Back off failed rows with seven retry deadlines rather than one case per row.

array
pending(string $database, int $limit)

Get a bounded set of pending rows for operator inspection.

object|null
find(string $database, string $uuid)

Find a stored message by its job UUID on the writer.

array
statistics(string $database)

Read backlog counts and the age of the first currently eligible row.

int
retry(string $database, string $uuid)

Retry an attempted message unless a live relay owns it.

int
retryAll(string $database)

Retry the current backlog in bounded primary-key chunks, preserving attempt counts.

bool
forget(string $database, int $id, string|null $leaseToken)

Delete an inspected row only while its lease remains inactive and unchanged.

retryable(ConnectionInterface $connection, int $now)

Select attempted rows that are safe for an operator to reschedule.

withoutLiveLease(Builder $query, int $now)

Exclude rows currently owned by a publishing relay.

whereIds(Builder $query, array $ids)

Restrict a query to selected IDs using InnoDB's primary index.

query(ConnectionInterface $connection)

Query the configured table on the writer, including for operator mutations.

Details

protected void insertDatabaseRows(ConnectionInterface $connection, string $table, array $rows)

Insert database rows without exceeding the connection's binding limit.

Parameters

ConnectionInterface $connection
string $table
array $rows

Return Value

void

protected void insertDatabaseRowChunk(ConnectionInterface $connection, string $table, array $rows)

Insert one database row chunk.

Parameters

ConnectionInterface $connection
string $table
array $rows

Return Value

void

protected int maxBindings(ConnectionInterface $connection)

Get the statement binding limit without requiring a PDO-backed custom driver.

Parameters

ConnectionInterface $connection

Return Value

int

in InteractsWithTime at line 17
protected int secondsUntil(DateInterval|DateTimeInterface|int $delay)

Get the number of seconds until the given DateTime.

Parameters

DateInterval|DateTimeInterface|int $delay

Return Value

int

in InteractsWithTime at line 29
protected int availableAt(DateInterval|DateTimeInterface|int|null $delay = 0)

Get the "available at" UNIX timestamp.

Parameters

DateInterval|DateTimeInterface|int|null $delay

Return Value

int

in InteractsWithTime at line 47
protected DateTimeInterface|int parseDateInterval(DateInterval|DateTimeInterface|int|null $delay)

If the given value is an interval, convert it to a DateTime instance.

Parameters

DateInterval|DateTimeInterface|int|null $delay

Return Value

DateTimeInterface|int

in InteractsWithTime at line 63
protected int currentTime()

Get the current system time as a UNIX timestamp.

Return Value

int

in InteractsWithTime at line 71
protected string runTimeForHumans(float $startTime, float|null $endTime = null)

Given a start time, format the total run time for human readability.

Parameters

float $startTime
float|null $endTime

Return Value

string

at line 30
__construct(ConnectionResolverInterface $resolver, array $databases, string $table, int $retryAfter)

Create a repository that resolves connections only for the current operation.

Parameters

ConnectionResolverInterface $resolver
array $databases
string $table
int $retryAfter

at line 50
array getDatabases()

Get the configured outbox sources.

Return Value

array

at line 58
Connection getConnection(string $database)

Resolve a configured outbox source in the current coroutine.

Parameters

string $database

Return Value

Connection

at line 72
void insert(ConnectionInterface $connection, array $rows)

Insert finalized rows on the connection that owns the business transaction.

Parameters

ConnectionInterface $connection
array $rows

Return Value

void

at line 82
array claim(string $database, int $limit)

Claim eligible messages without retaining a database resource in the result.

Parameters

string $database
int $limit

Return Value

array

at line 121
protected array claimOnPostgres(ConnectionInterface $connection, int $limit, int $now, int $expiresAt, string $token)

Claim a PostgreSQL batch in one statement, retaining its original eligibility.

Parameters

ConnectionInterface $connection
int $limit
int $now
int $expiresAt
string $token

Return Value

array

at line 144
protected array claimWithSkipLocked(ConnectionInterface $connection, int $limit, int $now, int $expiresAt, string $token)

Claim rows on engines that support skipping another relay's locked rows.

Parameters

ConnectionInterface $connection
int $limit
int $now
int $expiresAt
string $token

Return Value

array

at line 174
protected array claimWithConditionalUpdate(ConnectionInterface $connection, int $limit, int $now, int $expiresAt, string $token)

Win eligible candidates through one atomic update on engines without skip-locked support.

Parameters

ConnectionInterface $connection
int $limit
int $now
int $expiresAt
string $token

Return Value

array

at line 198
protected array getClaimedRows(ConnectionInterface $connection, array $candidates, string $token)

Read the rows owned by this claim with their original eligibility.

Parameters

ConnectionInterface $connection
array $candidates
string $token

Return Value

array

at line 216
int settle(string $database, array $messages, OutboxBatchResult $result)

Settle a validated result without modifying rows claimed by a newer relay.

Parameters

string $database
array $messages
OutboxBatchResult $result

Return Value

int

the number of rows still owned and settled

at line 254
protected int releaseFailed(ConnectionInterface $connection, string $token, array $ids, string $error)

Back off failed rows with seven retry deadlines rather than one case per row.

Parameters

ConnectionInterface $connection
string $token
array $ids
string $error

Return Value

int

at line 288
array pending(string $database, int $limit)

Get a bounded set of pending rows for operator inspection.

Parameters

string $database
int $limit

Return Value

array

at line 296
object|null find(string $database, string $uuid)

Find a stored message by its job UUID on the writer.

Parameters

string $database
string $uuid

Return Value

object|null

at line 306
array statistics(string $database)

Read backlog counts and the age of the first currently eligible row.

Parameters

string $database

Return Value

array

at line 333
int retry(string $database, string $uuid)

Retry an attempted message unless a live relay owns it.

Parameters

string $database
string $uuid

Return Value

int

at line 347
int retryAll(string $database)

Retry the current backlog in bounded primary-key chunks, preserving attempt counts.

Parameters

string $database

Return Value

int

at line 383
bool forget(string $database, int $id, string|null $leaseToken)

Delete an inspected row only while its lease remains inactive and unchanged.

Parameters

string $database
int $id
string|null $leaseToken

Return Value

bool

at line 392
protected Builder retryable(ConnectionInterface $connection, int $now)

Select attempted rows that are safe for an operator to reschedule.

Parameters

ConnectionInterface $connection
int $now

Return Value

Builder

at line 400
protected Builder withoutLiveLease(Builder $query, int $now)

Exclude rows currently owned by a publishing relay.

Parameters

Builder $query
int $now

Return Value

Builder

at line 412
protected Builder whereIds(Builder $query, array $ids)

Restrict a query to selected IDs using InnoDB's primary index.

Parameters

Builder $query
array $ids

Return Value

Builder

at line 426
protected Builder query(ConnectionInterface $connection)

Query the configured table on the writer, including for operator mutations.

Parameters

ConnectionInterface $connection

Return Value

Builder