ingredient/info: Add Fetcher concept
This commit is contained in:
parent
a6501b42c7
commit
52559e4d68
22 changed files with 447 additions and 328 deletions
|
|
@ -5,6 +5,7 @@ import (
|
|||
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/meta"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/locker"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/mstore"
|
||||
"github.com/tkw1536/goprogram/stream"
|
||||
|
|
@ -61,3 +62,14 @@ func (barrel Barrel) LastRebuild() (t time.Time, err error) {
|
|||
func (barrel *Barrel) setLastRebuild() error {
|
||||
return lastRebuild.Set(barrel.MStore, time.Now().Unix())
|
||||
}
|
||||
|
||||
type LastRebuildFetcher struct {
|
||||
ingredient.Base
|
||||
|
||||
Barrel *Barrel
|
||||
}
|
||||
|
||||
func (lbr *LastRebuildFetcher) Fetch(flags ingredient.FetchFlags, info *ingredient.Information) (err error) {
|
||||
info.LastRebuild, _ = lbr.Barrel.LastRebuild()
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package drush
|
|||
import (
|
||||
"time"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/php"
|
||||
"github.com/tkw1536/goprogram/exit"
|
||||
"github.com/tkw1536/goprogram/stream"
|
||||
|
|
@ -35,3 +36,18 @@ func (drush *Drush) LastCron(server *php.Server) (t time.Time, err error) {
|
|||
}
|
||||
return time.Unix(timestamp, 0), nil
|
||||
}
|
||||
|
||||
type LastCronFetcher struct {
|
||||
ingredient.Base
|
||||
|
||||
Drush *Drush
|
||||
}
|
||||
|
||||
func (lbr *LastCronFetcher) Fetch(flags ingredient.FetchFlags, info *ingredient.Information) (err error) {
|
||||
if flags.Quick {
|
||||
return
|
||||
}
|
||||
|
||||
info.LastRebuild, _ = lbr.Drush.LastCron(flags.Server)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/meta"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/mstore"
|
||||
"github.com/FAU-CDI/wisski-distillery/pkg/environment"
|
||||
"github.com/tkw1536/goprogram/exit"
|
||||
|
|
@ -46,3 +47,14 @@ func (drush *Drush) LastUpdate() (t time.Time, err error) {
|
|||
func (drush *Drush) setLastUpdate() error {
|
||||
return lastUpdate.Set(drush.MStore, time.Now().Unix())
|
||||
}
|
||||
|
||||
type LastUpdateFetcher struct {
|
||||
ingredient.Base
|
||||
|
||||
Drush *Drush
|
||||
}
|
||||
|
||||
func (lbr *LastUpdateFetcher) Fetch(flags ingredient.FetchFlags, info *ingredient.Information) (err error) {
|
||||
info.LastUpdate, err = lbr.Drush.LastUpdate()
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
package barrel
|
||||
|
||||
import "github.com/tkw1536/goprogram/stream"
|
||||
import (
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient"
|
||||
"github.com/tkw1536/goprogram/stream"
|
||||
)
|
||||
|
||||
// Running checks if this WissKI is currently running.
|
||||
func (barrel *Barrel) Running() (bool, error) {
|
||||
|
|
@ -10,3 +13,14 @@ func (barrel *Barrel) Running() (bool, error) {
|
|||
}
|
||||
return len(ps) > 0, nil
|
||||
}
|
||||
|
||||
type RunningFetcher struct {
|
||||
ingredient.Base
|
||||
|
||||
Barrel *Barrel
|
||||
}
|
||||
|
||||
func (rf *RunningFetcher) Fetch(flags ingredient.FetchFlags, info *ingredient.Information) (err error) {
|
||||
info.Running, err = rf.Barrel.Running()
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue