Documentation
¶
Overview ¶
Package resourcereclass applies the operator's resources.index rules again to the managed resources no writer chose an index policy for (#2111), in batches under an advisory lock, so a change to the rules reaches what is already stored without one burst of work per row.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrReclassifyRunning = errors.New("a reclassification is already running")
ErrReclassifyRunning reports a reclassification already under way.
Functions ¶
This section is empty.
Types ¶
type Reclassifier ¶
type Reclassifier struct {
// contains filtered or unexported fields
}
Reclassifier applies the operator's resources.index rules to the resources no writer chose a policy for, in batches.
func NewReclassifier ¶
func NewReclassifier(db *sql.DB, resolver *indexpolicy.Resolver, resources, folders *indexjobs.Producer) *Reclassifier
NewReclassifier builds a reclassifier. The producers receive the jobs a change owes: the resource's own when it becomes indexed, its folder's when it enters or leaves the set the folder is summarized over. Either may be nil.
func (*Reclassifier) Run ¶
func (r *Reclassifier) Run(ctx context.Context) (ReclassifyResult, error)
Run walks every resource once, in id order and in batches. A policy a writer chose is left as it is; every other is decided by the rules again. A row whose policy changes drops its vector and its kept text, so the index worker rebuilds what its new policy reads and nothing else; a row under a policy that reads no content keeps none. It holds an advisory lock for the whole walk and answers ErrReclassifyRunning when another holds it.
type ReclassifyResult ¶
type ReclassifyResult struct {
Examined int `json:"examined"`
Changed int `json:"changed"`
// Cleared is rows whose kept content text was removed because their
// policy reads none.
Cleared int `json:"cleared"`
}
ReclassifyResult is what one reclassification did.