Documentation
¶
Overview ¶
Package ingest drives the Slack source: discovery, change detection by object version, detail reads of what moved, and saves through the source's store.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Job ¶
type Job struct {
Every time.Duration
// Prepare builds one run's registration; a non-empty skip, such as a
// low budget, runs nothing and is the job's skipped text.
Prepare func(ctx context.Context, now time.Time) (p Plan, skip string, err error)
}
Job is a source's ingestion job: the daemon runs it every Every with RunJob.
type Plan ¶
type Plan struct {
Registration
// After runs once Run returns, with its report and error, and gives the
// job's outcome; nil summarizes the report and returns Run's error.
After func(ctx context.Context, rep Report, err error) (summary, skipped string, _ error)
}
Plan is one run of a Job.
type Registration ¶
type Registration struct {
Source Source
Store SourceStore
// Valid says why key is not a unit key of the source.
Valid func(key string) error
}
Registration is one source with its store and how its unit keys are checked.
type Report ¶
type Report struct {
Provider unit.ProviderID
Discovered, Moved int
Read []unit.Unit // units of the read facts, distinct, sorted by Unit.Less
Cursor string // the cursor saved by this pass
}
Report is what one pass did.
func Run ¶
Run is one two-phase pass: Discover from the stored cursor, Stubs of Watched (minus discovered), compare each object's Version with Versions, Read what moved or is unknown, Save (light facts of every stub, read facts, cursor), See every object returned. It spends no budget itself: the source's client does. Passes of one provider never interleave.
type Source ¶
type Source interface {
Provider() unit.ProviderID
Discover(ctx context.Context, cursor string) (stubs []Stub, next string, err error)
Stubs(ctx context.Context, objects []string) ([]Stub, error)
Read(ctx context.Context, objects []string) (Facts, error)
Viewer(ctx context.Context) (string, error)
}
Source reads the provider's objects. It never writes the store.
type SourceStore ¶
type SourceStore interface {
// Watched are the objects to stub-check every run with their stored versions;
// an object whose detail is older than its max age has Version "".
Watched(ctx context.Context) ([]Stub, error)
Versions(ctx context.Context, objects []string) (map[string]string, error)
Cursor(ctx context.Context) (string, error)
// Save stores light facts, then read facts (the read wins for one object),
// then the cursor. It runs on every pass, so read may be nil and light empty.
Save(ctx context.Context, light []Facts, read Facts, cursor string, at time.Time) error
// See stamps the objects as seen at at.
See(ctx context.Context, objects []string, at time.Time) error
}
SourceStore is the source's own persistence. Only ingest calls it.