Documentation
¶
Overview ¶
Package controller is the Outline controller: for every Outline workspace the policy declares, read what Outline holds and what the directory says of each of its people, decide, act where the workspace is enabled, and report.
It is built on the rails the GitHub and Slack controllers share (internal/rails, docs/decisions/0024): the pass loop, the policy guard on every answer of the console, the tick lease, the breaker fingerprints, the held-once ledger, the last-good-report journal and the dry-run switch.
One tick ¶
- The workspace's connection record and API key are read from the console's records. A workspace with none is waiting, not failed.
- Outline is read whole: the key's own user and the team settings, every account (the suspended included), the groups and the managed groups' members, the collections and the bound collections' grants and direct members. A read cut short of a group or a collection holds that one; of anything else, it fails the tick. A 429 fails the tick, which the next one tries again.
- Each account's address is put to the console's Explain, which resolves it as the issuer does (the directory's standing, then the policy), and every answer is held to this pass's policy digest.
- The decision (package reconcile), and, when the workspace is enabled (rails.Switch), the changes, each recorded to the audit trail.
- The workspace's report is published. A failed tick keeps its previous report with the failure on it.
Index ¶
- Constants
- Variables
- type Config
- type Controller
- func (c *Controller) Pass(ctx context.Context) (otherPolicy bool)
- func (c *Controller) Run(ctx context.Context) error
- func (c *Controller) RunTarget(ctx context.Context, target string) (ran, otherPolicy bool, err error)
- func (c *Controller) Targets() []string
- func (c *Controller) Tick(ctx context.Context, target string) (otherPolicy bool)
- type Deps
- type Directory
- type RecordSource
Constants ¶
const DefaultInterval = 2 * time.Minute
DefaultInterval is the time between two passes: short, because a person who signs in for the first time sees nothing but their own documents until the pass after.
DefaultShareScan is how often the single-document shares are read: each document is two calls, so not every pass.
const LeaseKind = "outline-tick"
LeaseKind is the kind of lease on a workspace's tick.
const MaxScannedDocuments = 5000
MaxScannedDocuments bounds a share scan; a workspace past it is reported and not scanned.
Variables ¶
var ErrUnknownTarget = errors.New("not a target of this controller")
ErrUnknownTarget is a target that is not a workspace the policy declares.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Interval is the time between passes. Zero is [DefaultInterval].
Interval time.Duration
PolicyRetry time.Duration
// Enabled are the workspaces the controller acts in. Every other is a
// dry run.
Enabled map[string]bool
// [DefaultShareScan]; negative never reads them.
ShareScan time.Duration
// RecordPoll is how often the records are looked at for a change or a
// request for a pass. Zero is thirty seconds; negative turns it off.
RecordPoll time.Duration
}
Config is what a deployment decides.
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller is the loop and what it remembers between passes.
func (*Controller) Pass ¶
func (c *Controller) Pass(ctx context.Context) (otherPolicy bool)
Pass is a sweep: every declared workspace once, each under its own lease. It says whether any answer came from a console under another policy.
func (*Controller) Run ¶
func (c *Controller) Run(ctx context.Context) error
Run passes now and then every interval until the context ends. A changed record wakes a pass at once, and an operator's request ticks its workspace.
func (*Controller) RunTarget ¶
func (c *Controller) RunTarget(ctx context.Context, target string) (ran, otherPolicy bool, err error)
RunTarget ticks one workspace under its lease and says whether it ran: false, with no error, when another runner holds the lease.
func (*Controller) Targets ¶
func (c *Controller) Targets() []string
Targets are the declared workspaces, by key.
type Deps ¶
type Deps struct {
Log *slog.Logger
Directory Directory
// Audit is where the controller records what it did. Nil records
// nothing.
Audit audit.Recorder
Status rails.Store
Records RecordSource
// Policy is the declared policy the controller decides with, and Digest
// its digest: an answer of the console under another is not acted on.
Policy policy.Policy
Digest string
// Outline makes the client of a workspace. Nil is Outline's own API.
Outline func(url, key string) *outlineapi.Client
// Leases takes a lease on each workspace before its tick. Nil runs every
// tick without one: a single runner.
Leases *rails.Leases
Now func() time.Time
}
Deps are what the controller talks to.
type Directory ¶
type Directory interface {
Explain(context.Context, *directoryrosterv1.ExplainRequest) (*directoryrosterv1.ExplainResponse, error)
ListServedDomains(context.Context, *directoryrosterv1.ListServedDomainsRequest) (*directoryrosterv1.ListServedDomainsResponse, error)
ResolveDirectoryGroups(context.Context, *directoryrosterv1.ResolveDirectoryGroupsRequest) (*directoryrosterv1.ResolveDirectoryGroupsResponse, error)
}
Directory is the console as this controller asks it: the three questions, each answered with the digest of the policy it was computed under. The generated AccessService client is one.
type RecordSource ¶
type RecordSource interface {
// Get is one workspace's record and API key; found is false when it is
// not connected.
Get(ctx context.Context, workspace string) (connection.Record, connection.Credential, bool, error)
// Confirmations are the operators' confirmations that still stand, of
// every workspace.
Confirmations(ctx context.Context) ([]connection.Confirmation, error)
// PassRequests are the operators' last requests for a pass now, by
// workspace.
PassRequests(ctx context.Context) (map[string]connection.PassRequest, error)
// Digest summarises the records, so a change wakes a pass.
Digest(ctx context.Context) ([32]byte, error)
}
RecordSource is where the console keeps the workspaces' records (internal/portstore.OutlineWorkspaces).