modes

package
v0.0.0-...-f3bf748 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: BSD-3-Clause Imports: 8 Imported by: 5

Documentation

Index

Constants

View Source
const (
	ModeRunning = "running"
	ModeStopped = "stopped"
	ModeDryRun  = "dry run"
	ModeOffline = "offline"
)

Valid autoroller modes.

View Source
const (
	// ModeHistoryLength is the number of mode changes which may be returned
	// from ModeHistory.GetHistory().
	ModeHistoryLength = 25
)

Variables

View Source
var (
	// ValidModes lists the valid autoroller modes.
	ValidModes = []string{
		ModeRunning,
		ModeDryRun,
		ModeStopped,
		ModeOffline,
	}
)

Functions

This section is empty.

Types

type DatastoreModeHistory

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

DatastoreModeHistory is a ModeHistory which uses Datastore.

func NewDatastoreModeHistory

func NewDatastoreModeHistory(ctx context.Context, roller string) (*DatastoreModeHistory, error)

NewDatastoreModeHistory returns a DatastoreModeHistory instance.

func (*DatastoreModeHistory) Add

func (mh *DatastoreModeHistory) Add(ctx context.Context, mode, user, message string) error

Add inserts a new ModeChange.

func (*DatastoreModeHistory) CurrentMode

func (mh *DatastoreModeHistory) CurrentMode() *ModeChange

CurrentMode returns the current mode, which is the most recently added ModeChange.

func (*DatastoreModeHistory) GetHistory

func (mh *DatastoreModeHistory) GetHistory(ctx context.Context, offset int) ([]*ModeChange, int, error)

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

func (*DatastoreModeHistory) Update

func (mh *DatastoreModeHistory) Update(ctx context.Context) error

Update refreshes the mode history from the datastore.

type ModeChange

type ModeChange struct {
	Message string    `datastore:"message" json:"message"`
	Mode    string    `datastore:"mode" json:"mode"`
	Roller  string    `datastore:"roller" json:"-"`
	Time    time.Time `datastore:"time" json:"time"`
	User    string    `datastore:"user" json:"user"`
}

ModeChange is a struct used for describing a change in the AutoRoll mode.

func (*ModeChange) Copy

func (c *ModeChange) Copy() *ModeChange

Copy returns a copy of the ModeChange.

type ModeHistory

type ModeHistory interface {
	// Add a new ModeChange.
	Add(ctx context.Context, mode, user, message string) error
	// CurrentMode retrieves the most recent ModeChange.
	CurrentMode() *ModeChange
	// GetHistory returns a slice of recent ModeChanges. Its length is bounded
	// by ModeHistoryLength.
	GetHistory(ctx context.Context, offset int) ([]*ModeChange, int, error)
	// Update the local view of the ModeChange history.
	Update(ctx context.Context) error
}

ModeHistory tracks the history of mode changes for the autoroller.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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