monitor

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2018 License: Apache-2.0 Imports: 16 Imported by: 6

Documentation

Overview

Package monitor is a helper for keeping a local in memory representation of the key data from some of the robot services. It's purpose is to provice the main data source for packages like the web server and the scheduler. Most of the types are opaque about their contents to allow for lazy aquisition construction or lookup of their members. For instance, id's are normally resolved to objects for you, but that resolve may not happen until the member is asked for.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, managers Managers, owner DataOwner, update func(ctx context.Context, managers *Managers, data *Data) []error) error

Run is used to run a new monitor. It will monitor the data from all the managers that are in the supplied managers, filling in the data structure with all the results it receives. Each time it receives a batch of updates it will invoke the update function passing in the manager set being monitored and the updated set of data.

Types

type Data

type Data struct {
	Gen *Generation

	Devices  Devices
	Workers  Workers
	Subjects Subjects
	Tracks   Tracks
	Packages Packages
	Traces   Traces
	Reports  Reports
	Replays  Replays
	// contains filtered or unexported fields
}

Data is the live store of data from the monitored servers. Entries with no live manager will not be updated.

func (*Data) FindDevice

func (data *Data) FindDevice(id string) *Device

FindDevice searches the device list for one that matches the supplied id.

func (*Data) Wait

func (data *Data) Wait()

type DataOwner

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

func NewDataOwner

func NewDataOwner() DataOwner

func (DataOwner) Read

func (o DataOwner) Read(rf func(d *Data))

func (DataOwner) Write

func (o DataOwner) Write(wf func(d *Data))

type Device

type Device struct {
	job.Device
}

Device is the in memory representation/wrapper for a job.Device

type Devices

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

Devices is the type that manages a set of Device objects.

func (*Devices) All

func (d *Devices) All() []*Device

All returns the complete set of Device objects we have seen so far.

type Generation

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

Generation is a way to handle sequences of 'updates' or 'generations', find out how many have happened, as well as blocking until the next one happens. This does not assume an 'update' to mean anything specific.

func NewGeneration

func NewGeneration() *Generation

NewGeneration returns a new Generation starting with an id of 0.

func (*Generation) After

func (g *Generation) After(id uint64) <-chan struct{}

After returns a channel that will be closed as soon as the generation exceeds ID. This is intended for use in select calls, if you just want to wait, WaitForUpdate is more efficient.

func (*Generation) Get

func (g *Generation) Get() (uint64, chan struct{})

Get returns the generation identifier and blocking channel under the lock

func (*Generation) ID

func (g *Generation) ID() uint64

ID returns the current generation identifier under the lock

func (*Generation) Update

func (g *Generation) Update() uint64

Update increments the generation and notifies all blocked goroutines

func (*Generation) WaitForUpdate

func (g *Generation) WaitForUpdate(previous uint64) uint64

WaitForUpdate blocks until the generation is past previous, and returns the current generation.

type Managers

type Managers struct {
	Master  master.Master
	Stash   *stash.Client
	Job     job.Manager
	Build   build.Store
	Subject subject.Subjects
	Trace   trace.Manager
	Report  report.Manager
	Replay  replay.Manager
}

Managers describes the set of managers to monitor for data changes.

type Package

type Package struct {
	build.Package
	// contains filtered or unexported fields
}

Package is the in memory representation/wrapper for a build.Package

func (*Package) FindTools

func (p *Package) FindTools(ctx context.Context, d *Device) *build.ToolSet

FindTools returns the tool set that matches the supplied device, if the package has one.

func (*Package) FindToolsForAPK

func (p *Package) FindToolsForAPK(ctx context.Context, host *Device, target *Device, apkInfo *apk.Information) *build.AndroidToolSet

FindToolsForAPK returns the best matching tool set for a certain apk on a device, if present in the package.

func (*Package) FindToolsForDevice added in v1.1.0

func (p *Package) FindToolsForDevice(ctx context.Context, host *Device, target *Device) *build.AndroidToolSet

FindToolsForDevice returns the best matching tool set for a certain device.

type Packages

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

Packages is the type that manages a set of Package objects.

func (*Packages) All

func (p *Packages) All() []*Package

All returns the complete set of Package objects we have seen so far.

type Replay

type Replay struct {
	replay.Action
}

Replay is the in memory representation/wrapper for a replay.Action

type Replays

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

Replays is the type that manages a set of Replay objects.

func (*Replays) All

func (r *Replays) All() []*Replay

All returns the complete set of Replay objects we have seen so far.

func (*Replays) Find

func (r *Replays) Find(ctx context.Context, action *replay.Action) *Replay

Find searches the replays for the one that matches the supplied action. See worker.EquivalentAction for more information about how actions are compared.

func (*Replays) FindOrCreate

func (r *Replays) FindOrCreate(ctx context.Context, action *replay.Action) (*Replay, bool)

FindOrCreate returns the replay that matches the supplied action if it exists, if not it creates a new replay object, and returns it. It does not register the newly created replay object for you, that will happen only if a call is made to trigger the action on the replay service.

type Report

type Report struct {
	report.Action
}

Report is the in memory representation/wrapper for a report.Action

type Reports

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

Reports is the type that manages a set of Report objects.

func (*Reports) All

func (r *Reports) All() []*Report

All returns the complete set of Report objects we have seen so far.

func (*Reports) Find

func (r *Reports) Find(ctx context.Context, action *report.Action) *Report

Find searches the reports for the one that matches the supplied action. See worker.EquivalentAction for more information about how actions are compared.

func (*Reports) FindOrCreate

func (r *Reports) FindOrCreate(ctx context.Context, action *report.Action) (*Report, bool)

FindOrCreate returns the report that matches the supplied aciton if it exists, if not it creates a new report object, and returns it. It does not register the newly created report object for you, that will happen only if a call is made to trigger the action on the report service.

type Subject

type Subject struct {
	subject.Subject
}

Subject is the in memory representation/wrapper for a subject.Subject

type Subjects

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

Subjects is the type that manages a set of Subject objects.

func (*Subjects) All

func (s *Subjects) All() []*Subject

All returns the complete set of Subject objects we have seen so far.

func (*Subjects) Get added in v1.1.0

func (s *Subjects) Get(id string) *Subject

Get returns the Subject which has the given Id, returns nil if such a Subject is not found.

type Trace

type Trace struct {
	trace.Action
}

Trace is the in memory representation/wrapper for a trace.Action

type Traces

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

Traces is the type that manages a set of Trace objects.

func (*Traces) All

func (t *Traces) All() []*Trace

All returns the complete set of Trace objects we have seen so far.

func (*Traces) Find

func (t *Traces) Find(ctx context.Context, action *trace.Action) *Trace

Find searches the traces for the one that matches the supplied action. See worker.EquivalentAction for more information about how actions are compared.

func (*Traces) FindOrCreate

func (t *Traces) FindOrCreate(ctx context.Context, action *trace.Action) (*Trace, bool)

FindOrCreate returns the trace that matches the supplied aciton if it exists, if not it creates a new trace object, and returns it. It does not register the newly created trace object for you, that will happen only if a call is made to trigger the action on the trace service.

func (*Traces) MatchPackage added in v0.6.0

func (t *Traces) MatchPackage(p *Package) []*Trace

MatchPackage returns the set of Trace objects that were traced with a specific package.

type Track

type Track struct {
	build.Track
	// contains filtered or unexported fields
}

Track is the in memory representation/wrapper for a build.Track

type Tracks

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

Tracks is the type that manages a set of Track objects.

func (*Tracks) All

func (t *Tracks) All() []*Track

All returns the complete set of Track objects we have seen so far.

type Worker

type Worker struct {
	job.Worker
}

Worker is the in memory representation/wrapper for a job.Worker

type Workers

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

Workers is the type that manages a set of Worker objects.

func (*Workers) All

func (w *Workers) All() []*Worker

All returns the complete set of Worker objects we have seen so far.

Jump to

Keyboard shortcuts

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