Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cooldown ¶
type Cooldown struct {
// contains filtered or unexported fields
}
Cooldown provides atomic per-channel threshold cooldown via Redis. Key = c3api:notification:balance-warning:email:<userID>:<thresholdMillis> Value = random token, NX EX 86400. Only the token owner may delete.
func NewCooldown ¶
NewCooldown constructs a cooldown helper. client must be non-nil (Redis is a required dependency; nil panics to surface wiring errors early).
func (*Cooldown) Clear ¶
Clear deletes a known retired threshold claim regardless of token ownership. Preference updates intentionally retire the entire old warning cycle.
func (*Cooldown) Release ¶
func (c *Cooldown) Release(ctx context.Context, event domain.BalanceWarningEvent, token string) error
Release atomically deletes the key only if the stored value equals token. Uses Lua compare-delete to avoid GET->DEL race.
func (*Cooldown) TryClaim ¶
func (c *Cooldown) TryClaim(ctx context.Context, event domain.BalanceWarningEvent) (string, bool, error)
TryClaim attempts to atomically claim the cooldown slot. It returns (token, true, nil) on success (caller owns the claim), (\"\", false, nil) when another claimant holds it, or an error on Redis failure.
type WarningMailEnqueue ¶
type WarningMailEnqueue func(domain.BalanceWarningEvent, func(error)) error