botman

package
v0.0.0-...-6070400 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2025 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package botman provides a bot manager that ensures that designated Swarming bots are running, restarting them if necessary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Botman

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

Botman manages running Swarming bots. Callers tell Botman what bots to add, drain, or terminate using an ID, and Botman makes sure there are bots running or not running for those IDs. IDs may refer to resources such as DUTs or some arbitrary index of bots to run.

func NewBotman

func NewBotman(h WorldHook) *Botman

NewBotman creates a new Botman.

func (*Botman) ActiveBots

func (b *Botman) ActiveBots() []string

ActiveBots returns a slice of all Bots the controller is keeping alive. This includes Bots that are draining or terminated but not exited yet. This method is safe to call concurrently.

func (*Botman) AddBot

func (b *Botman) AddBot(id string)

AddBot adds a bot to the Botman. The controller ensures that an instance Swarming bot is running for the given resource ID. If the bot was already added or if the controller is blocked, do nothing. This method is concurrency safe.

func (*Botman) BlockBots

func (b *Botman) BlockBots()

BlockBots marks the controller to not accept new Bots. This method is safe to call concurrently.

func (*Botman) DrainAll

func (b *Botman) DrainAll()

DrainAll drains all Bots. You almost certainly want to call BlockBots first to make sure Bots don't get added right after calling this.

func (*Botman) DrainBot

func (b *Botman) DrainBot(id string)

DrainBot removes an ID to no longer have bots running for it and drains its current bot. This method can be called repeatedly. If the controller does not have the ID, just call ReleaseResources on the controller's hook. This method is concurrency safe.

func (*Botman) TerminateAll

func (b *Botman) TerminateAll()

TerminateAll terminates all Bots. You almost certainly want to call BlockBots first to make sure Bots don't get added right after calling this.

func (*Botman) TerminateBot

func (b *Botman) TerminateBot(id string)

TerminateBot removes an ID to no longer have bots running for it and terminates its current bot. This method can be called repeatedly. If the controller does not have the ID, just call ReleaseResources on the controller's hook. This method is concurrency safe.

func (*Botman) Wait

func (b *Botman) Wait()

Wait for all Swarming bots to finish. It is the caller's responsibility to make sure all bots are terminated or drained, else this call will hang.

type WorldHook

type WorldHook interface {
	// StartBot starts a bot process for the given ID.
	// This method should be safe to call concurrently.
	StartBot(id string) (bot.Bot, error)
	// ReleaseResources is called to release resources for a bot process
	// that has finished.  This method should be idempotent.
	ReleaseResources(id string)
}

WorldHook defines the interface that a Botman uses to interact with the external world.

Jump to

Keyboard shortcuts

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