Documentation
¶
Overview ¶
Package holds reads Staff holds (ADR 0009): the reversible freezes a service sets on a Workspace's outbound sending. It is the one place that decides a hold is active, so the send path, the site API and the console agree: a hold is active while its expiry is after the clock, and a lapsed one is ignored at once, with no cleanup job.
It also sets (idempotently) and clears a hold for the service endpoints in ee/staff, which only authorize and validate. It works through the scoped client and holds no raw client.
Index ¶
Constants ¶
const ( ReasonSuspended = "workspace_suspended" ReasonPendingDeletion = "workspace_pending_deletion" ReasonStaff = "staff_hold" )
The Workspace-level reasons a send is Held. They describe the Workspace, not one send, so they live with the holds (ADR 0009) and Outbound send reports them. Suspension (ADR 0007) is neither a Hold row nor the pending-deletion Hold: it keeps its own state and fields, and only its reason code is declared here.
const KeyPendingDeletion = "pending_deletion"
KeyPendingDeletion is the key of the pending-deletion Hold (ADR 0043).
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Change ¶
Change is the outcome of setting or clearing a hold: the hold concerned (nil when a clear found none) and whether the call changed anything.
func Clear ¶
Clear removes the hold under key. Clearing a missing hold succeeds and changes nothing.
type Holds ¶
type Holds struct {
// contains filtered or unexported fields
}
Holds answers the send path's "may this Workspace send now" from the standing. The one thing that varies between editions is whether Staff holds are honoured (the `staff` license); it is the one function the constructor takes.
func New ¶
New builds the module. honoured reports whether Staff holds count at all (deletion and suspension always do); now is the clock a hold's expiry is read against.
type Input ¶
type Input struct {
ReasonCode string
Message string
// ActionURL is where the Workspace's Owners and Admins can resolve the hold; nil for none.
ActionURL *string
ExpiresAt time.Time
}
Input is what a setter states about a hold.
type Standing ¶
type Standing struct {
// Deletion is the pending-deletion Hold of a deleted Workspace, nil for a live one.
// It is not a row: Workspace deletion is its own source and lifts on restore. It
// lasts to the erase date, the end of the window.
Deletion *ent.Hold
// SuspendedAt is when the Workspace was suspended (ADR 0007), nil when it is not.
SuspendedAt *time.Time
// Staff are the active Staff holds by key: none without the `staff` license.
Staff []*ent.Hold
}
Standing is a Workspace's standing: its independent freeze sources, never merged (glossary: Workspace suspension and Staff hold are independent reasons). Reason names the one a send reports, in priority order: deletion, suspension, Staff holds.
func Read ¶
Read is the standing of the scope's Workspace at now, one query for its row and one for its active Staff holds (none are read without the license).