pool: Reddo component-like fields

This commit is contained in:
Tom Wiesing 2022-12-22 13:49:05 +01:00
parent 99983ee6db
commit 337a5fbeba
No known key found for this signature in database
48 changed files with 291 additions and 163 deletions

View file

@ -17,10 +17,10 @@ import (
//
// It also logs the current time into the metadata belonging to this instance.
func (barrel *Barrel) Build(ctx context.Context, progress io.Writer, start bool) error {
if !barrel.Locker.TryLock(ctx) {
if !barrel.Dependencies.Locker.TryLock(ctx) {
return locker.Locked
}
defer barrel.Locker.Unlock(ctx)
defer barrel.Dependencies.Locker.Unlock(ctx)
stack := barrel.Stack()
@ -48,7 +48,7 @@ func (barrel *Barrel) Build(ctx context.Context, progress io.Writer, start bool)
var lastRebuild = mstore.For[int64]("lastRebuild")
func (barrel Barrel) LastRebuild(ctx context.Context) (t time.Time, err error) {
epoch, err := lastRebuild.Get(ctx, barrel.MStore)
epoch, err := lastRebuild.Get(ctx, barrel.Dependencies.MStore)
if err == meta.ErrMetadatumNotSet {
return t, nil
}
@ -61,16 +61,17 @@ func (barrel Barrel) LastRebuild(ctx context.Context) (t time.Time, err error) {
}
func (barrel *Barrel) setLastRebuild(ctx context.Context) error {
return lastRebuild.Set(ctx, barrel.MStore, time.Now().Unix())
return lastRebuild.Set(ctx, barrel.Dependencies.MStore, time.Now().Unix())
}
type LastRebuildFetcher struct {
ingredient.Base
Barrel *Barrel
Dependencies struct {
Barrel *Barrel
}
}
func (lbr *LastRebuildFetcher) Fetch(ctx context.Context, flags ingredient.FetcherFlags, info *status.WissKI) (err error) {
info.LastRebuild, _ = lbr.Barrel.LastRebuild(ctx)
info.LastRebuild, _ = lbr.Dependencies.Barrel.LastRebuild(ctx)
return
}