recent_rolls

package
v0.0.0-...-594fe3c 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: 13 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// Number of rolls to return from GetRecentRolls().
	RecentRollsLength = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB interface {
	// Put inserts a roll into the RollsDB.
	Put(ctx context.Context, roller string, roll *autoroll.AutoRollIssue) error
	// Get retrieves a roll from the RollsDB.
	Get(ctx context.Context, roller string, issue int64) (*autoroll.AutoRollIssue, error)
	// GetRolls loads rolls from the database. Returns the rolls and a cursor
	// which may be used to retrieve more rolls.
	GetRolls(ctx context.Context, roller string, cursor string) ([]*autoroll.AutoRollIssue, string, error)
}

type DatastoreRollsDB

type DatastoreRollsDB struct{}

DatastoreRollsDB implements RollsDB using Datastore.

func NewDatastoreRollsDB

func NewDatastoreRollsDB(ctx context.Context) *DatastoreRollsDB

NewDatastoreRollsDB returns a RollsDB instance which uses Datastore.

func (*DatastoreRollsDB) Get

func (d *DatastoreRollsDB) Get(ctx context.Context, roller string, issue int64) (*autoroll.AutoRollIssue, error)

Get implements RollsDB.

func (*DatastoreRollsDB) GetRolls

func (d *DatastoreRollsDB) GetRolls(ctx context.Context, roller, cursor string) ([]*autoroll.AutoRollIssue, string, error)

LoadRolls implements RollsDB.

func (*DatastoreRollsDB) Put

func (d *DatastoreRollsDB) Put(ctx context.Context, roller string, roll *autoroll.AutoRollIssue) error

Put implements RollsDB.

type DsRoll

type DsRoll struct {
	// Data is the gob-serialized AutoRollIssue.
	Data []byte `datastore:"data,noindex"`

	// Name of the roller.
	Roller string `datastore:"roller"`

	// RollerCreated is synthesized from the roller name and the creation
	// time of the roll. This helps to keep the overall index well-
	// distributed.
	RollerCreated string `datastore:"rollerCreated"`

	// RollerIssue is synthesized from the roller name and the issue ID of
	// the roll. This helps to keep the overall index well-distributed. This
	// field is used as the ID in datastore.
	RollerIssue string `datastore:"rollerIssue"`
}

DsRoll is a struct used for storing autoroll.AutoRollIssue objects in datastore. The AutoRollIssue is gob-serialized before and after inserting to simplify the interactions with datastore.

type RecentRolls

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

RecentRolls is a struct used for storing and retrieving recent DEPS rolls.

func NewRecentRolls

func NewRecentRolls(ctx context.Context, db DB, roller string) (*RecentRolls, error)

NewRecentRolls returns a new RecentRolls instance.

func (*RecentRolls) Add

Add adds a DEPS roll to the recent rolls list.

func (*RecentRolls) CurrentRoll

func (r *RecentRolls) CurrentRoll() *autoroll.AutoRollIssue

CurrentRoll returns a copy of the currently-active DEPS roll, or nil if none exists.

func (*RecentRolls) Get

func (r *RecentRolls) Get(ctx context.Context, issue int64) (*autoroll.AutoRollIssue, error)

Get returns the given roll.

func (*RecentRolls) GetRecentRolls

func (r *RecentRolls) GetRecentRolls() []*autoroll.AutoRollIssue

GetRecentRolls returns a copy of the recent rolls list.

func (*RecentRolls) LastRoll

func (r *RecentRolls) LastRoll() *autoroll.AutoRollIssue

LastRoll returns a copy of the last DEPS roll, if one exists, and nil otherwise.

func (*RecentRolls) LastSuccessfulRollTime

func (r *RecentRolls) LastSuccessfulRollTime() time.Time

LastSuccessfulRollTime returns the timestamp of the last successful roll.

func (*RecentRolls) NumFailedRolls

func (r *RecentRolls) NumFailedRolls() int

NumFailedRolls returns the number of failed rolls since the last successful roll.

func (*RecentRolls) Update

func (r *RecentRolls) Update(ctx context.Context, roll *autoroll.AutoRollIssue) error

Update updates the given DEPS roll in the recent rolls list.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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