Documentation ¶
Index ¶
- Constants
- Variables
- func GetTaskSpec(ctx context.Context, c TaskCfgCache, rs types.RepoState, name string) (*specs.TaskSpec, error)
- func MakeJob(ctx context.Context, c TaskCfgCache, rs types.RepoState, name string) (*types.Job, error)
- func WriteTasksCfgToBigTable(ctx context.Context, table *bigtable.Table, key string, cv *CachedValue) error
- type CachedValue
- type TaskCfgCache
- type TaskCfgCacheImpl
- func (c *TaskCfgCacheImpl) Cleanup(ctx context.Context, period time.Duration) error
- func (c *TaskCfgCacheImpl) Close() error
- func (c *TaskCfgCacheImpl) Get(ctx context.Context, rs types.RepoState) (*specs.TasksCfg, error, error)
- func (c *TaskCfgCacheImpl) Set(ctx context.Context, rs types.RepoState, cfg *specs.TasksCfg, storedErr error) error
- func (c *TaskCfgCacheImpl) SetIfUnset(ctx context.Context, rs types.RepoState, ...) (*CachedValue, error)
Constants ¶
const ( // We use a single BigTable table for storing gob-encoded TaskSpecs and // JobSpecs. BT_TABLE = "tasks-cfg" // We use a single BigTable column family. BT_COLUMN_FAMILY = "CFGS" // We use a single BigTable column which stores gob-encoded TaskSpecs // and JobSpecs. BT_COLUMN = "CFG" INSERT_TIMEOUT = 30 * time.Second QUERY_TIMEOUT = 5 * time.Second )
Variables ¶
var ( // Fully-qualified BigTable column name. BT_COLUMN_FULL = fmt.Sprintf("%s:%s", BT_COLUMN_FAMILY, BT_COLUMN) ErrNoSuchEntry = atomic_miss_cache.ErrNoSuchEntry )
Functions ¶
func GetTaskSpec ¶
func GetTaskSpec(ctx context.Context, c TaskCfgCache, rs types.RepoState, name string) (*specs.TaskSpec, error)
GetTaskSpec returns the TaskSpec at the given RepoState, or an error if no such TaskSpec exists.
func MakeJob ¶
func MakeJob(ctx context.Context, c TaskCfgCache, rs types.RepoState, name string) (*types.Job, error)
MakeJob is a helper function which retrieves the given JobSpec at the given RepoState and uses it to create a Job instance.
func WriteTasksCfgToBigTable ¶
func WriteTasksCfgToBigTable(ctx context.Context, table *bigtable.Table, key string, cv *CachedValue) error
WriteTasksCfgToBigTable writes the given CachedValue to BigTable.
Types ¶
type CachedValue ¶
type CachedValue struct { // RepoState is the RepoState which is associated with this TasksCfg. RepoState types.RepoState // Cfg is the TasksCfg for this entry. Cfg *specs.TasksCfg // Err stores a permanent error. Mutually-exclusive with Cfg. Err string }
CachedValue represents a cached TasksCfg value. It includes any permanent error, which cannot be recovered via retries.
func GetTasksCfgFromBigTable ¶
func GetTasksCfgFromBigTable(ctx context.Context, table *bigtable.Table, rowKey string) (*CachedValue, error)
GetTasksCfgFromBigTable retrieves a CachedValue from BigTable.
type TaskCfgCache ¶
type TaskCfgCache interface { // Cleanup removes cache entries which are outside of our scheduling window. Cleanup(ctx context.Context, period time.Duration) error // Close frees up resources used by the TaskCfgCache. Close() error // Get returns the TasksCfg (or error) for the given RepoState in the cache. // If the given entry does not exist in the cache, reads through to the // backing store to find it there and adds to the cache if it exists. If no // entry exists for the given RepoState, returns ErrNoSuchEntry. If there is // a cached (ie. permanent non-recoverable) error for this RepoState, it is // returned as the second return value. Get(context.Context, types.RepoState) (*specs.TasksCfg, error, error) // Sets the TasksCfg (or error) for the given RepoState in the cache. Set(ctx context.Context, rs types.RepoState, cfg *specs.TasksCfg, storedErr error) error // Sets the TasksCfg (or error) for the given RepoState in the cache by // calling the given function if no value already exists. Returns the // existing or new CachedValue, or any error which occurred. SetIfUnset(ctx context.Context, rs types.RepoState, fn func(context.Context) (*CachedValue, error)) (*CachedValue, error) }
type TaskCfgCacheImpl ¶
type TaskCfgCacheImpl struct {
// contains filtered or unexported fields
}
TaskCfgCacheImpl is a struct used for caching tasks cfg files. The user should periodically call Cleanup() to remove old entries.
func NewTaskCfgCache ¶
func NewTaskCfgCache(ctx context.Context, repos repograph.Map, btProject, btInstance string, ts oauth2.TokenSource) (*TaskCfgCacheImpl, error)
NewTaskCfgCache returns a TaskCfgCache instance.
func (*TaskCfgCacheImpl) Cleanup ¶
Cleanup removes cache entries which are outside of our scheduling window.
func (*TaskCfgCacheImpl) Close ¶
func (c *TaskCfgCacheImpl) Close() error
Close implements TaskCfgCache.
func (*TaskCfgCacheImpl) Get ¶
func (c *TaskCfgCacheImpl) Get(ctx context.Context, rs types.RepoState) (*specs.TasksCfg, error, error)
Get implements TaskCfgCache.
func (*TaskCfgCacheImpl) Set ¶
func (c *TaskCfgCacheImpl) Set(ctx context.Context, rs types.RepoState, cfg *specs.TasksCfg, storedErr error) error
Sets the TasksCfg (or error) for the given RepoState in the cache.
func (*TaskCfgCacheImpl) SetIfUnset ¶
func (c *TaskCfgCacheImpl) SetIfUnset(ctx context.Context, rs types.RepoState, fn func(context.Context) (*CachedValue, error)) (*CachedValue, error)
Sets the TasksCfg (or error) for the given RepoState in the cache by calling the given function if no value already exists. Returns the existing or new CachedValue, or any error which occurred.