Documentation ¶
Index ¶
- Constants
- Variables
- type DatastoreModeHistory
- func (mh *DatastoreModeHistory) Add(ctx context.Context, mode, user, message string) error
- func (mh *DatastoreModeHistory) CurrentMode() *ModeChange
- func (mh *DatastoreModeHistory) GetHistory(ctx context.Context, offset int) ([]*ModeChange, int, error)
- func (mh *DatastoreModeHistory) Update(ctx context.Context) error
- type ModeChange
- type ModeHistory
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.
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.
Click to show internal directories.
Click to hide internal directories.