scan

package
v0.0.0-...-6f45537 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package scan implements functionality for scanning Swarming datastore.

It is used by `monitor` binary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActiveTasks

func ActiveTasks(ctx context.Context, visitors []TaskVisitor) error

ActiveTasks visits all pending and running tasks.

Returns a multi-error with the scan error (if any) and errors from all visitors' finalizers (if any) in arbitrary order.

func Bots

func Bots(ctx context.Context, visitors []BotVisitor) error

Bots visits all bots via multiple parallel queries.

Returns a multi-error with the scan error (if any) and errors from all visitors' finalizers (if any) in arbitrary order.

Types

type ActiveJobsReporter

type ActiveJobsReporter struct {
	// ServiceName is a service name to put into metrics' target.
	ServiceName string
	// JobName is a job name to put into metrics' target.
	JobName string
	// Monitor to use to flush metrics.
	Monitor monitor.Monitor
	// contains filtered or unexported fields
}

ActiveJobsReporter is TaskVisitor that reports the number of active jobs per combination of dimensions to monitoring.

func (*ActiveJobsReporter) Finalize

func (r *ActiveJobsReporter) Finalize(ctx context.Context, scanErr error) error

Finalize is called once the scan is done.

Part of TaskVisitor interface.

func (*ActiveJobsReporter) Prepare

func (r *ActiveJobsReporter) Prepare(ctx context.Context)

Prepare prepares the visitor state.

Part of TaskVisitor interface.

func (*ActiveJobsReporter) Visit

Visit is called for every visited task.

Part of TaskVisitor interface.

type BotVisitor

type BotVisitor interface {
	// Prepare prepares the visitor to use `shards` parallel queries.
	//
	// It should initialize per-shard state used by Visit.
	Prepare(ctx context.Context, shards int)

	// Visit is called for every bot.
	//
	// The overall scan is split into multiple shards. Within a shard the scan is
	// sequential, but shards themselves are processed in parallel.
	Visit(ctx context.Context, shard int, bot *model.BotInfo)

	// Finalize is called once the scan is done.
	//
	// It is passed an error if the scan was incomplete. If the scan was complete,
	// (i.e. Visit visited all bots), it receives nil.
	//
	// The returned error will be reported as an overall scan error.
	Finalize(ctx context.Context, scanErr error) error
}

BotVisitor examines bots in parallel.

Should keep track of errors internally during the scan, reporting them only in the end in Finalize.

type BotsDimensionsAggregator

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

BotsDimensionsAggregator is BotVisitor that collects the set of all possible bot dimensions and stores it in the datastore.

The result is used by GetBotDimensions RPCs.

func (*BotsDimensionsAggregator) Finalize

func (a *BotsDimensionsAggregator) Finalize(ctx context.Context, scanErr error) error

Finalize is called once the scan is done.

Part of BotVisitor interface.

func (*BotsDimensionsAggregator) Prepare

func (a *BotsDimensionsAggregator) Prepare(ctx context.Context, shards int)

Prepare prepares the visitor to use `shards` parallel queries.

Part of BotVisitor interface.

func (*BotsDimensionsAggregator) Visit

func (a *BotsDimensionsAggregator) Visit(ctx context.Context, shard int, bot *model.BotInfo)

Visit is called for every bot.

Part of BotVisitor interface.

type BotsMetricsReporter

type BotsMetricsReporter struct {
	// ServiceName is a service name to put into metrics' target.
	ServiceName string
	// JobName is a job name to put into metrics' target.
	JobName string
	// Monitor to use to flush metrics.
	Monitor monitor.Monitor
	// contains filtered or unexported fields
}

BotsMetricsReporter is BotVisitor that reports stats about bots to the monitoring.

func (*BotsMetricsReporter) Finalize

func (r *BotsMetricsReporter) Finalize(ctx context.Context, scanErr error) error

Finalize is called once the scan is done.

Part of BotVisitor interface.

func (*BotsMetricsReporter) Prepare

func (r *BotsMetricsReporter) Prepare(ctx context.Context, shards int)

Prepare prepares the visitor to use `shards` parallel queries.

Part of BotVisitor interface.

func (*BotsMetricsReporter) Visit

func (r *BotsMetricsReporter) Visit(ctx context.Context, shard int, bot *model.BotInfo)

Visit is called for every bot.

Part of BotVisitor interface.

type TaskVisitor

type TaskVisitor interface {
	// Prepare prepares the visitor state.
	//
	// It should initialize the state used by Visit.
	Prepare(ctx context.Context)

	// Visit is called for every visited task.
	//
	// Called sequentially from a single goroutine.
	Visit(ctx context.Context, task *model.TaskResultSummary)

	// Finalize is called once the scan is done.
	//
	// It is passed an error if the scan was incomplete. If the scan was complete,
	// (i.e. Visit visited all tasks), it receives nil.
	//
	// The returned error will be reported as an overall scan error.
	Finalize(ctx context.Context, scanErr error) error
}

TaskVisitor examines tasks, **sequentially**.

Should keep track of errors internally during the scan, reporting them only in the end in Finalize.

Jump to

Keyboard shortcuts

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