Documentation
¶
Overview ¶
Package analyze implements idu's commands that create and maintain the database: analyze, logs, errors (both of which can erase entries) and database locate. Progress reporting is supplied by the caller via NewProgress, so that main controls how, and whether, it is displayed.
Index ¶
- type Commands
- func (alz *Commands) Analyze(ctx context.Context, values interface{}, args []string) error
- func (c *Commands) Errors(ctx context.Context, values interface{}, args []string) error
- func (c *Commands) Locate(_ context.Context, values interface{}, args []string) error
- func (c *Commands) Logs(ctx context.Context, values interface{}, args []string) error
- type ErrorFlags
- type Flags
- type LocateFlags
- type LogFlags
- type NewProgress
- type Option
- type Progress
- type SnapshotFunc
- type Summary
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Commands ¶
type Commands struct {
// contains filtered or unexported fields
}
Commands implements the commands that create and maintain the database, ie. analyze, logs, errors and database locate.
type ErrorFlags ¶
type ErrorFlags struct {
cli.FSFlag
Prefix bool `subcmd:"prefix,false,list errors by prefix"`
Erase bool `subcmd:"erase,false,erase the errors rather than displaying them"`
}
ErrorFlags are the flags for the errors command.
type Flags ¶
type Flags struct {
cli.FSFlag
Progress bool `subcmd:"progress,true,show progress"`
Force bool `subcmd:"force,false,reanalyze even if the database is up to date"`
SlowScans time.Duration `subcmd:"slow-scan-duration,10s,duration at which scans are reported as slow"`
Defaults bool `subcmd:"show-defaults,false,display default scanning options and exit"`
Snapshot bool `` /* 194-byte string literal not displayed */
RefreshTopN bool `` /* 203-byte string literal not displayed */
}
Flags are the flags for the analyze command.
type LocateFlags ¶
LocateFlags are the flags for the database locate command.
type LogFlags ¶
type LogFlags struct {
cli.FSFlag
Range flags.TimeInterval `` /* 280-byte string literal not displayed */
Erase bool `subcmd:"erase,false,erase the logs rather than displaying them"`
JSON bool `subcmd:"json,true,display logs in json format"`
}
LogFlags are the flags for the logs command.
type NewProgress ¶
NewProgress creates the Progress for an analysis, display is true if the progress should be displayed as the analysis proceeds. Any display must stop when ctx is canceled or Stop is called.
type Option ¶
type Option func(*Commands)
Option configures the Commands created by New.
func WithOutput ¶
WithOutput sets the writer for the messages, other than progress, that are displayed during an analysis, eg. its configuration, it defaults to os.Stdout.
func WithProgress ¶
func WithProgress(newProgress NewProgress) Option
WithProgress sets the function used to create the Progress for each analysis. Without it progress is neither displayed nor reported.
func WithSnapshot ¶
func WithSnapshot(fn SnapshotFunc) Option
WithSnapshot sets the function used to write a snapshot once an analysis has completed, as requested by --snapshot, which is an error without it.
type Progress ¶
type Progress interface {
idudb.ScanProgress
// Stop stops any display of the progress of the analysis and waits
// for it to finish.
Stop()
// Summary returns the progress counters, the caller fills in the
// Operation, Command and Duration fields.
Summary() Summary
// Report displays, and logs, a final summary of the analysis.
Report(ctx context.Context)
}
Progress is notified of the progress of an analysis and reports on it.
type SnapshotFunc ¶
SnapshotFunc writes a snapshot of the stats for the entire filesystem f, computed from its database, to its snapshot_dir and returns its path.
type Summary ¶
type Summary struct {
Operation string `json:"operation"`
Command string `json:"command"`
Duration time.Duration `json:"duration"`
PrefixesStarted int64 `json:"prefixes_started"`
PrefixesFinished int64 `json:"prefixes_finished"`
SynchronousScans int64 `json:"synchronous_scans"`
SlowScans int64 `json:"slow_scans"`
FSStats int64 `json:"fs_stats"`
FSStatsTotal int64 `json:"fs_stats_total"`
FSStatMeanLatency int64 `json:"fs_stat_mean_latency"`
Files int64 `json:"files"`
ParentUnchanged int64 `json:"parent_unchanged"`
ChildrenUnchanged int64 `json:"children_unchanged"`
Errors int64 `json:"errors"`
PrefixesDeleted int64 `json:"prefixes_deleted"`
FilesRestated int64 `json:"files_restated"`
FilesRestatedChanged int64 `json:"files_restated_changed"`
}
Summary is the summary of an analysis that is recorded, as JSON, in the database log and displayed by the logs command.