class DeferredWebhookManager

Properties

protected array<string, int> $pending

Pending timer IDs keyed by "{type}:{appId}:{channel}[:{userId}]".

protected bool $draining

Whether the manager is in draining mode (worker shutting down).

protected Timer $timer

Methods

__construct()

Create a new deferred webhook manager instance.

void
deferChannelVacated(Application $app, string $channel, float $delaySeconds, int $smoothingTtlMs)

Schedule a deferred channel_vacated webhook.

void
deferMemberRemoved(Application $app, string $channel, string $userId, float $delaySeconds, int $smoothingTtlMs)

Schedule a deferred member_removed webhook.

bool
cancelChannelVacated(string $appId, string $channel)

Cancel a pending deferred channel_vacated webhook.

bool
cancelMemberRemoved(string $appId, string $channel, string $userId)

Cancel a pending deferred member_removed webhook.

void
cancelAll()

Cancel all pending deferred webhook timers without firing them.

void
setDraining(bool $draining)

Enable draining mode (worker shutting down).

bool
isDraining()

Determine whether the manager is in draining mode.

bool
cancel(string $key)

Cancel a pending timer by key.

Details

at line 31
__construct()

Create a new deferred webhook manager instance.

at line 39
void deferChannelVacated(Application $app, string $channel, float $delaySeconds, int $smoothingTtlMs)

Schedule a deferred channel_vacated webhook.

Parameters

Application $app
string $channel
float $delaySeconds
int $smoothingTtlMs

Return Value

void

at line 67
void deferMemberRemoved(Application $app, string $channel, string $userId, float $delaySeconds, int $smoothingTtlMs)

Schedule a deferred member_removed webhook.

Parameters

Application $app
string $channel
string $userId
float $delaySeconds
int $smoothingTtlMs

Return Value

void

at line 98
bool cancelChannelVacated(string $appId, string $channel)

Cancel a pending deferred channel_vacated webhook.

Returns true if a pending timer was cancelled (same-worker fast path).

Parameters

string $appId
string $channel

Return Value

bool

at line 108
bool cancelMemberRemoved(string $appId, string $channel, string $userId)

Cancel a pending deferred member_removed webhook.

Returns true if a pending timer was cancelled (same-worker fast path).

Parameters

string $appId
string $channel
string $userId

Return Value

bool

at line 119
void cancelAll()

Cancel all pending deferred webhook timers without firing them.

NOT called during shutdown — pending timers fire naturally via the WORKER_EXIT coordinator. This method exists for testing cleanup.

Return Value

void

at line 134
void setDraining(bool $draining)

Enable draining mode (worker shutting down).

When draining, callers should fire webhooks immediately instead of deferring them.

Parameters

bool $draining

Return Value

void

at line 142
bool isDraining()

Determine whether the manager is in draining mode.

Return Value

bool

at line 150
protected bool cancel(string $key)

Cancel a pending timer by key.

Parameters

string $key

Return Value

bool