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

@ -20,7 +20,7 @@ var errCronFailed = exit.Error{
}
func (drush *Drush) Cron(ctx context.Context, progress io.Writer) error {
code := drush.Barrel.Shell(ctx, stream.NonInteractive(progress), "/runtime/cron.sh")()
code := drush.Dependencies.Barrel.Shell(ctx, stream.NonInteractive(progress), "/runtime/cron.sh")()
if code != 0 {
// keep going, because we want to run as many crons as possible
logging.ProgressF(progress, ctx, "%v", errCronFailed.WithMessageF(drush.Slug, code))
@ -31,7 +31,7 @@ func (drush *Drush) Cron(ctx context.Context, progress io.Writer) error {
func (drush *Drush) LastCron(ctx context.Context, server *phpx.Server) (t time.Time, err error) {
var timestamp int64
err = drush.PHP.EvalCode(ctx, server, &timestamp, `$val = \Drupal::state()->get('system.cron_last'); return $val; `)
err = drush.Dependencies.PHP.EvalCode(ctx, server, &timestamp, `$val = \Drupal::state()->get('system.cron_last'); return $val; `)
if err != nil {
return
}
@ -40,8 +40,9 @@ func (drush *Drush) LastCron(ctx context.Context, server *phpx.Server) (t time.T
type LastCronFetcher struct {
ingredient.Base
Drush *Drush
Dependencies struct {
Drush *Drush
}
}
var (
@ -53,6 +54,6 @@ func (lbr *LastCronFetcher) Fetch(flags ingredient.FetcherFlags, info *status.Wi
return
}
info.LastRebuild, _ = lbr.Drush.LastCron(flags.Context, flags.Server)
info.LastRebuild, _ = lbr.Dependencies.Drush.LastCron(flags.Context, flags.Server)
return
}

View file

@ -10,8 +10,9 @@ import (
// Drush implements commands related to drush
type Drush struct {
ingredient.Base
Barrel *barrel.Barrel
MStore *mstore.MStore
PHP *php.PHP
Dependencies struct {
Barrel *barrel.Barrel
MStore *mstore.MStore
PHP *php.PHP
}
}

View file

@ -20,7 +20,7 @@ var errBlindUpdateFailed = exit.Error{
// Update performs a blind drush update
func (drush *Drush) Update(ctx context.Context, progress io.Writer) error {
code := drush.Barrel.Shell(ctx, stream.NonInteractive(progress), "/runtime/blind_update.sh")()
code := drush.Dependencies.Barrel.Shell(ctx, stream.NonInteractive(progress), "/runtime/blind_update.sh")()
if code != 0 {
return errBlindUpdateFailed.WithMessageF(drush.Slug, code)
}
@ -31,7 +31,7 @@ func (drush *Drush) Update(ctx context.Context, progress io.Writer) error {
const lastUpdate = mstore.For[int64]("lastUpdate")
func (drush *Drush) LastUpdate(ctx context.Context) (t time.Time, err error) {
epoch, err := lastUpdate.Get(ctx, drush.MStore)
epoch, err := lastUpdate.Get(ctx, drush.Dependencies.MStore)
if err == meta.ErrMetadatumNotSet {
return t, nil
}
@ -44,13 +44,14 @@ func (drush *Drush) LastUpdate(ctx context.Context) (t time.Time, err error) {
}
func (drush *Drush) setLastUpdate(ctx context.Context) error {
return lastUpdate.Set(ctx, drush.MStore, time.Now().Unix())
return lastUpdate.Set(ctx, drush.Dependencies.MStore, time.Now().Unix())
}
type LastUpdateFetcher struct {
ingredient.Base
Drush *Drush
Dependencies struct {
Drush *Drush
}
}
var (
@ -58,6 +59,6 @@ var (
)
func (lbr *LastUpdateFetcher) Fetch(flags ingredient.FetcherFlags, info *status.WissKI) (err error) {
info.LastUpdate, err = lbr.Drush.LastUpdate(flags.Context)
info.LastUpdate, err = lbr.Dependencies.Drush.LastUpdate(flags.Context)
return
}