Documentation
¶
Overview ¶
Package catalogprune deletes the catalog rows a catalog release stopped shipping once nothing holds them. A versioned reseed only marks such rows detached (meta.CatalogDetachedAt); a prune deletes a detached row that is not operator-edited, carries no overlay, is referenced by nothing but other detached rows deleted with it, and, for a model or a host binding, served no request inside the idle window. A model an operator's policy names in spec.models also stays. Every other detached row stays, and the next prune judges it again.
What references a row is the caller's answer (the control API's delete blockers and dropped links), so a prune and an admin delete agree on what holds a row. Out of scope: rows that never came from the catalog, usage history (never touched), and anything on the request path.
Index ¶
Constants ¶
const ( Prune = "prune" Keep = "keep" )
Decision values.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decision ¶
type Decision struct {
Kind string `` /* 127-byte string literal not displayed */
Name string `json:"name" doc:"Slug of the row."`
ID string `json:"id" doc:"Id of the row."`
DetachedAt time.Time `json:"detachedAt" doc:"When a catalog release stopped shipping the row."`
Decision string `` /* 159-byte string literal not displayed */
Reason string `` /* 205-byte string literal not displayed */
// Owner and version are what the delete and its audit row need; Deleted
// is set once the row is gone, which a run that fails part-way needs said.
Owner meta.Owner `json:"-"`
Deleted bool `json:"-"`
// contains filtered or unexported fields
}
Decision is what a prune decided for one detached row.
type Options ¶
type Options struct {
// Idle is how long a model or host binding must have served no request.
Idle time.Duration
// Apply deletes the rows decided prune; false only decides.
Apply bool
// References lists the rows referencing the row id of kind (an API singular).
References func(ctx context.Context, kind, id string) ([]Ref, error)
// Usage answers the traffic guard; nil leaves it unknown.
Usage UsageReader
// Now defaults to time.Now.
Now func() time.Time
}
Options configures one prune.
type Ref ¶
type Ref struct {
// Kind is the referencing row's kind as an API singular (policy, host-key, …).
Kind string
ID string
Name string
}
Ref is a row that references a candidate.
type Report ¶
type Report struct {
// Idle is the traffic window the prune judged by.
Idle time.Duration
Rows []Decision
// Pruned counts the rows deleted, or that a dry run would delete.
Pruned int
// Kept counts the rows that stay detached.
Kept int
Applied bool
}
Report is what a prune decided and, when it applied, did.
type Stores ¶
type Stores struct {
Providers Table[provider.Provider]
Hosts Table[host.Host]
Models Table[model.Model]
Pricings Table[pricing.Pricing]
Bindings Table[binding.Binding]
Policies Table[policy.Policy]
RateLimits Table[ratelimit.RateLimit]
Overlays Overlays
}
Stores are the kinds a release can drop.
type Table ¶
type Table[T any] interface { List(ctx context.Context) ([]*T, error) DeleteAtVersion(ctx context.Context, id, version string) error }
Table lists one kind and deletes a row of it only while the row still has the version that was read.
type UsageReader ¶
type UsageReader interface {
Events(ctx context.Context, q usage.EventQuery) ([]usage.Event, error)
}
UsageReader is the one usage read the traffic guard makes.