strategy

package
v0.0.0-...-c8d90df Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: BSD-3-Clause Imports: 9 Imported by: 5

Documentation

Index

Constants

View Source
const (
	ROLL_STRATEGY_BATCH = "batch"
	// TODO(rmistry): Rename to "batch of " + N_REVISIONS ?
	ROLL_STRATEGY_N_BATCH = "n_batch"
	ROLL_STRATEGY_SINGLE  = "single"

	// The number of Revisions to use in ROLL_STRATEGY_N_BATCH.
	N_REVISIONS = 20
)
View Source
const (
	// StrategyHistoryLength is the number of StrategyChanges which may be
	// returned by StrategyHistory.GetHistory().
	StrategyHistoryLength = 25
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DatastoreStrategyHistory

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

DatastoreStrategyHistory is a struct used for storing and retrieving strategy change history.

func NewDatastoreStrategyHistory

func NewDatastoreStrategyHistory(ctx context.Context, roller string, validStrategies []string) (*DatastoreStrategyHistory, error)

NewDatastoreStrategyHistory returns a StrategyHistory instance.

func (*DatastoreStrategyHistory) Add

func (sh *DatastoreStrategyHistory) Add(ctx context.Context, s, user, message string) error

Add inserts a new StrategyChange.

func (*DatastoreStrategyHistory) CurrentStrategy

func (sh *DatastoreStrategyHistory) CurrentStrategy() *StrategyChange

CurrentStrategy returns the current strategy, which is the most recently added StrategyChange.

func (*DatastoreStrategyHistory) GetHistory

func (sh *DatastoreStrategyHistory) GetHistory(ctx context.Context, offset int) ([]*StrategyChange, int, error)

GetHistory returns a slice of the most recent StrategyChanges, most recent first.

func (*DatastoreStrategyHistory) Update

Update refreshes the strategy history from the datastore.

type NextRollStrategy

type NextRollStrategy interface {
	// Return the next roll revision, given the list of not-yet-rolled
	// Revisions in reverse chronological order. Returning nil implies that
	// we cannot create a roll; we are up to date, or there are no valid
	// revisions to roll.
	GetNextRollRev([]*revision.Revision) *revision.Revision
}

NextRollStrategy is an interface for modules which determine what the next roll Revision should be.

func GetNextRollStrategy

func GetNextRollStrategy(strategy string) (NextRollStrategy, error)

Return the NextRollStrategy indicated by the given string.

func StrategyBatch

func StrategyBatch() NextRollStrategy

StrategyBatch returns a NextRollStrategy which always rolls to HEAD of a given branch.

func StrategyNBatch

func StrategyNBatch() NextRollStrategy

StrategyNBatch returns a NextRollStrategy which always rolls to maximum N Revisions of a given branch.

func StrategySingle

func StrategySingle() NextRollStrategy

StrategySingle returns a NextRollStrategy which rolls toward HEAD of a given branch, one Revision at a time.

type StrategyChange

type StrategyChange struct {
	Message  string    `datastore:"message" json:"message"`
	Strategy string    `datastore:"strategy" json:"strategy"`
	Roller   string    `datastore:"roller" json:"-"`
	Time     time.Time `datastore:"time" json:"time"`
	User     string    `datastore:"user" json:"user"`
}

StrategyChange is a struct used for describing a change in the AutoRoll strategy.

func (*StrategyChange) Copy

func (c *StrategyChange) Copy() *StrategyChange

Copy returns a copy of the StrategyChange.

type StrategyHistory

type StrategyHistory interface {
	// Add inserts a new StrategyChange.
	Add(ctx context.Context, s, user, message string) error
	// CurrentStrategy returns the current strategy, which is the most recently added
	// StrategyChange.
	CurrentStrategy() *StrategyChange
	// GetHistory returns a slice of the most recent StrategyChanges, most recent first.
	GetHistory(ctx context.Context, offset int) ([]*StrategyChange, int, error)
	// Update refreshes the strategy history from the datastore.
	Update(ctx context.Context) error
}

StrategyHistory tracks the history of StrategyChanges for all autorollers.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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