sweep

package
v0.1.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sweep is the daily job of the terms of keeping (R05, R21, R38): it finishes the deletions the requests left unfinished and deletes what E2 keeps past its term — accounts and profiles idle for 12 months, users of the sign-in service with no account for 30 days, dangling tuples, and the records of keys and OpenFGA's changelog after a day. A pass keeps no state for the next: each step chooses its work again by a query, so a pass cut short is taken up by the next one. Its log is counts alone.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB interface {
	store.Beginner
	store.Querier
	store.Lister
}

DB is the database api: a pool.

type Report

type Report []Step

Report is the steps of a pass, in their order.

func (Report) Clean

func (r Report) Clean() bool

Clean says whether the pass did all it had to: every step to its end, with no failure. A term that depends on the job runs to its next clean pass (R21).

type Rights

type Rights interface {
	deletion.Rights
	Tuples(ctx context.Context) iter.Seq2[authz.Owned, error]
	DropChangelog(ctx context.Context, before time.Time) (int64, error)
}

Rights is what the job asks of the rights: authz.Rights.

type Signin

type Signin interface {
	deletion.Signin
	Users(ctx context.Context) iter.Seq2[authn.User, error]
}

Signin is what the job asks of the sign-in service: authn.Port.

type Step

type Step struct {
	Name     string
	Done     int64
	Failed   int64
	Finished bool
}

Step is what a step of a pass did: how many it did and failed, and whether it went to its end — not cut short by the pass's time, and its own queries done.

type Sweeper

type Sweeper struct {
	// contains filtered or unexported fields
}

Sweeper runs the passes of the job.

func New

func New(db DB, rights Rights, signin Signin, settle time.Duration, log *slog.Logger) *Sweeper

New is the job on db, rights and signin. settle is the longest a request may run: a mark or a tuple younger than that may be a request's still going, and the job leaves it.

func (*Sweeper) Run

func (s *Sweeper) Run(ctx context.Context, now time.Time) Report

Run runs one pass at now, until ctx ends: the steps in their order, so that the tuples and the changelog the deletions leave go in the same pass. A step that fails goes on to the next item, and the next step runs all the same; once ctx is done, every step left stops before its first item.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL