diff --git a/internal/dis/component/control/home/public.go b/internal/dis/component/control/home/public.go index 79cef52..2e85625 100644 --- a/internal/dis/component/control/home/public.go +++ b/internal/dis/component/control/home/public.go @@ -8,7 +8,7 @@ import ( _ "embed" "github.com/FAU-CDI/wisski-distillery/internal/dis/component/control/static" - "github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient" + "github.com/FAU-CDI/wisski-distillery/internal/status" "github.com/FAU-CDI/wisski-distillery/pkg/timex" "github.com/tkw1536/goprogram/stream" "golang.org/x/sync/errgroup" @@ -65,7 +65,7 @@ func (home *Home) homeRender() ([]byte, error) { if err != nil { return nil, err } - context.Instances = make([]ingredient.Information, len(wissKIs)) + context.Instances = make([]status.Information, len(wissKIs)) // determine their infos var eg errgroup.Group @@ -86,7 +86,7 @@ func (home *Home) homeRender() ([]byte, error) { } type HomeContext struct { - Instances []ingredient.Information + Instances []status.Information Time time.Time diff --git a/internal/dis/component/control/info/index.go b/internal/dis/component/control/info/index.go index 2bd83ee..8bf9200 100644 --- a/internal/dis/component/control/info/index.go +++ b/internal/dis/component/control/info/index.go @@ -8,7 +8,7 @@ import ( "github.com/FAU-CDI/wisski-distillery/internal/dis/component" "github.com/FAU-CDI/wisski-distillery/internal/dis/component/control/static" - "github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient" + "github.com/FAU-CDI/wisski-distillery/internal/status" "golang.org/x/sync/errgroup" ) @@ -20,18 +20,18 @@ var indexTemplate = static.AssetsControlIndex.MustParseShared( ) type indexContext struct { - component.Observation - Instances []ingredient.Information + status.Distillery + Instances []status.Information } func (info *Info) index(r *http.Request) (idx indexContext, err error) { - idx.Observation, idx.Instances, err = info.Status(true) + idx.Distillery, idx.Instances, err = info.Status(true) return } // Status produces a new observation of the distillery, and a new information of all instances // The information on all instances is passed the given quick flag. -func (info *Info) Status(QuickInformation bool) (observation component.Observation, information []ingredient.Information, err error) { +func (info *Info) Status(QuickInformation bool) (target status.Distillery, information []status.Information, err error) { var group errgroup.Group group.Go(func() error { @@ -42,7 +42,7 @@ func (info *Info) Status(QuickInformation bool) (observation component.Observati } // get all of their info! - information = make([]ingredient.Information, len(all)) + information = make([]status.Information, len(all)) for i, instance := range all { { i := i @@ -59,34 +59,34 @@ func (info *Info) Status(QuickInformation bool) (observation component.Observati }) // gather all the observations - var flags component.ObservationFlags - for _, o := range info.Obervers { + var flags component.FetcherFlags + for _, o := range info.Fetchers { o := o group.Go(func() error { - return o.Observe(flags, &observation) + return o.Fetch(flags, &target) }) } - // wait for all the observes to finish + // wait for all the fetchers to finish if err := group.Wait(); err != nil { - return component.Observation{}, nil, err + return status.Distillery{}, nil, err } // count overall instances for _, i := range information { if i.Running { - observation.RunningCount++ + target.RunningCount++ } else { - observation.StoppedCount++ + target.StoppedCount++ } } - observation.TotalCount = len(information) + target.TotalCount = len(information) return } -func (nfo *Info) Observe(flags component.ObservationFlags, observation *component.Observation) error { - observation.Time = time.Now().UTC() - observation.Config = nfo.Config +func (nfo *Info) Fetch(flags component.FetcherFlags, target *status.Distillery) error { + target.Time = time.Now().UTC() + target.Config = nfo.Config return nil } diff --git a/internal/dis/component/control/info/info.go b/internal/dis/component/control/info/info.go index f3d1723..06941e6 100644 --- a/internal/dis/component/control/info/info.go +++ b/internal/dis/component/control/info/info.go @@ -18,7 +18,7 @@ type Info struct { component.Base Analytics *lazy.PoolAnalytics - Obervers []component.Observer + Fetchers []component.DistilleryFetcher Exporter *exporter.Exporter Instances *instances.Instances diff --git a/internal/dis/component/control/info/instance.go b/internal/dis/component/control/info/instance.go index ec1da08..c3e1541 100644 --- a/internal/dis/component/control/info/instance.go +++ b/internal/dis/component/control/info/instance.go @@ -9,7 +9,7 @@ import ( "github.com/FAU-CDI/wisski-distillery/internal/dis/component/control/static" "github.com/FAU-CDI/wisski-distillery/internal/dis/component/instances" "github.com/FAU-CDI/wisski-distillery/internal/models" - "github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient" + "github.com/FAU-CDI/wisski-distillery/internal/status" "github.com/FAU-CDI/wisski-distillery/pkg/httpx" ) @@ -24,7 +24,7 @@ type instanceContext struct { Time time.Time Instance models.Instance - Info ingredient.Information + Info status.Information } func (info *Info) instance(r *http.Request) (is instanceContext, err error) { diff --git a/internal/dis/component/exporter/logger/logger.go b/internal/dis/component/exporter/logger/logger.go index 49fac81..7482cc5 100644 --- a/internal/dis/component/exporter/logger/logger.go +++ b/internal/dis/component/exporter/logger/logger.go @@ -4,6 +4,7 @@ import ( "github.com/FAU-CDI/wisski-distillery/internal/dis/component" "github.com/FAU-CDI/wisski-distillery/internal/dis/component/sql" "github.com/FAU-CDI/wisski-distillery/internal/models" + "github.com/FAU-CDI/wisski-distillery/internal/status" "github.com/FAU-CDI/wisski-distillery/pkg/environment" "github.com/tkw1536/goprogram/lib/collection" ) @@ -77,8 +78,8 @@ func (log *Logger) Add(export models.Export) error { return nil } -// Observe writes the SnapshotLog into the given observation -func (logger *Logger) Observe(flags component.ObservationFlags, observation *component.Observation) (err error) { - observation.Backups, err = logger.For("") +// Fetch writes the SnapshotLog into the given observation +func (logger *Logger) Fetch(flags component.FetcherFlags, target *status.Distillery) (err error) { + target.Backups, err = logger.For("") return } diff --git a/internal/dis/component/fetcher.go b/internal/dis/component/fetcher.go new file mode 100644 index 0000000..313e26f --- /dev/null +++ b/internal/dis/component/fetcher.go @@ -0,0 +1,14 @@ +package component + +import "github.com/FAU-CDI/wisski-distillery/internal/status" + +type DistilleryFetcher interface { + Component + + // Fetch fetches information from this component and writes it into target. + // Distinct DistilleryFetchers must write into distinct fields. + Fetch(flags FetcherFlags, target *status.Distillery) error +} + +// FetcherFlags describes options for a DistilleryFetcher +type FetcherFlags struct{} diff --git a/internal/dis/component/watcher.go b/internal/dis/component/watcher.go deleted file mode 100644 index f5fade2..0000000 --- a/internal/dis/component/watcher.go +++ /dev/null @@ -1,34 +0,0 @@ -package component - -import ( - "time" - - "github.com/FAU-CDI/wisski-distillery/internal/config" - "github.com/FAU-CDI/wisski-distillery/internal/models" -) - -// Observer is a component with an Observe method -type Observer interface { - Component - - // Observe observes this distillery component and writes the result into observation - // Distinct Observers must write into distinct fields. - Observe(flags ObservationFlags, observation *Observation) error -} - -type ObservationFlags struct{} - -// Observation represents fetched information about the distillery -type Observation struct { - Time time.Time // Time this obervation was built - - // Configuration of the distillery - Config *config.Config - - // number of instances - TotalCount int - RunningCount int - StoppedCount int - - Backups []models.Export // list of backups -} diff --git a/internal/status/distillery.go b/internal/status/distillery.go new file mode 100644 index 0000000..b5565e3 --- /dev/null +++ b/internal/status/distillery.go @@ -0,0 +1,23 @@ +package status + +import ( + "time" + + "github.com/FAU-CDI/wisski-distillery/internal/config" + "github.com/FAU-CDI/wisski-distillery/internal/models" +) + +// Distillery holds status and analytical data about a distillery +type Distillery struct { + Time time.Time // Time when this information was built + + // Configuration of the distillery + Config *config.Config + + // number of instances + TotalCount int + RunningCount int + StoppedCount int + + Backups []models.Export // list of backups +} diff --git a/internal/status/information.go b/internal/status/information.go new file mode 100644 index 0000000..e0a0da4 --- /dev/null +++ b/internal/status/information.go @@ -0,0 +1,117 @@ +package status + +import ( + "fmt" + "time" + + "github.com/FAU-CDI/wisski-distillery/internal/models" + "github.com/FAU-CDI/wisski-distillery/internal/phpx" +) + +// Information provides information about a single WissKI +type Information struct { + Time time.Time // Time this info was built + + Slug string // slug + URL string // complete URL, including http(s) + + Locked bool // Is this instance currently locked? + + // Information about the running instance + Running bool + LastRebuild time.Time + LastUpdate time.Time + LastCron time.Time + + // Statistics of the WissKI + Statistics Statistics + + // List of backups made + Snapshots []models.Export + + // List of SSH Keys + SSHKeys []string + + // WissKI content information + NoPrefixes bool // TODO: Move this into the database + Prefixes []string // list of prefixes + Pathbuilders map[string]string // all the pathbuilders +} + +// Statistics holds statistics generated by the WissKI module +type Statistics struct { + Activity struct { + MostVisited string `json:"mostVisited"` + PageVisits []struct { + URL string `json:"url"` + Visits int `json:"visits"` + } `json:"pageVisits"` + TotalEditsLastWeek int `json:"totalEditsLastWeek"` + } `json:"activity"` + Bundles BundleStatistics `json:"bundles"` + Triplestore struct { + Graphs []struct { + URI string `json:"uri"` + Count int `json:"triples"` + } `json:"graphStatistics"` + Total int `json:"totalTriples"` + } `json:"triplestore"` + Users struct { + LastLogin string `json:"lastLogin"` + TotalUsers int `json:"totalUsers"` + } `json:"users"` +} + +type BundleStatistics struct { + Bundles []struct { + Label string `json:"label"` + MachineName string `json:"machineName"` + + Count int `json:"entities"` + + LastEdit phpx.TimeInt `json:"lastEdit"` + + MainBundle phpx.PHPBoolean `json:"mainBundle"` + } `json:"bundleStatistics"` + TotalBundles int `json:"totalBundles"` + TotalMainBundles int `json:"totalMainBundles"` +} + +type LastEdit struct { + Time time.Time + Valid bool +} + +// LastEdit returns the last time any bundle was edited, and if any edit was bigger than the reference time +func (bs BundleStatistics) LastEdit() (le LastEdit) { + for _, bundle := range bs.Bundles { + time := bundle.LastEdit.Time() + if time.After(le.Time) { + le.Valid = true + le.Time = time + } + } + return +} + +func (bs BundleStatistics) Summary() string { + var totalCount int + for _, bundle := range bs.Bundles { + totalCount += bundle.Count + } + if totalCount == 0 { + return "" + } + + entitySubject := "Entities" + if totalCount == 1 { + entitySubject = "Entity" + } + + bundleSubject := "Bundles" + if len(bs.Bundles) == 1 { + bundleSubject = "Bundle" + } + + return fmt.Sprintf("%d %s in %d %s", totalCount, entitySubject, len(bs.Bundles), bundleSubject) +} diff --git a/internal/status/status.go b/internal/status/status.go new file mode 100644 index 0000000..55a6d01 --- /dev/null +++ b/internal/status/status.go @@ -0,0 +1,2 @@ +// Package status provides status information +package status diff --git a/internal/wisski/ingredient/barrel/build.go b/internal/wisski/ingredient/barrel/build.go index 5502e4f..f0a6609 100644 --- a/internal/wisski/ingredient/barrel/build.go +++ b/internal/wisski/ingredient/barrel/build.go @@ -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/status" "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" @@ -69,7 +70,7 @@ type LastRebuildFetcher struct { Barrel *Barrel } -func (lbr *LastRebuildFetcher) Fetch(flags ingredient.FetchFlags, info *ingredient.Information) (err error) { +func (lbr *LastRebuildFetcher) Fetch(flags ingredient.FetcherFlags, info *status.Information) (err error) { info.LastRebuild, _ = lbr.Barrel.LastRebuild() return } diff --git a/internal/wisski/ingredient/barrel/drush/cron.go b/internal/wisski/ingredient/barrel/drush/cron.go index cd208b2..738058b 100644 --- a/internal/wisski/ingredient/barrel/drush/cron.go +++ b/internal/wisski/ingredient/barrel/drush/cron.go @@ -4,6 +4,7 @@ import ( "time" "github.com/FAU-CDI/wisski-distillery/internal/phpx" + "github.com/FAU-CDI/wisski-distillery/internal/status" "github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient" "github.com/tkw1536/goprogram/exit" "github.com/tkw1536/goprogram/stream" @@ -43,7 +44,7 @@ type LastCronFetcher struct { Drush *Drush } -func (lbr *LastCronFetcher) Fetch(flags ingredient.FetchFlags, info *ingredient.Information) (err error) { +func (lbr *LastCronFetcher) Fetch(flags ingredient.FetcherFlags, info *status.Information) (err error) { if flags.Quick { return } diff --git a/internal/wisski/ingredient/barrel/drush/update.go b/internal/wisski/ingredient/barrel/drush/update.go index 0141200..6a62128 100644 --- a/internal/wisski/ingredient/barrel/drush/update.go +++ b/internal/wisski/ingredient/barrel/drush/update.go @@ -4,6 +4,7 @@ import ( "time" "github.com/FAU-CDI/wisski-distillery/internal/dis/component/meta" + "github.com/FAU-CDI/wisski-distillery/internal/status" "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" @@ -54,7 +55,7 @@ type LastUpdateFetcher struct { Drush *Drush } -func (lbr *LastUpdateFetcher) Fetch(flags ingredient.FetchFlags, info *ingredient.Information) (err error) { +func (lbr *LastUpdateFetcher) Fetch(flags ingredient.FetcherFlags, info *status.Information) (err error) { info.LastUpdate, err = lbr.Drush.LastUpdate() return } diff --git a/internal/wisski/ingredient/barrel/running.go b/internal/wisski/ingredient/barrel/running.go index f71dbc8..bcfd107 100644 --- a/internal/wisski/ingredient/barrel/running.go +++ b/internal/wisski/ingredient/barrel/running.go @@ -1,6 +1,7 @@ package barrel import ( + "github.com/FAU-CDI/wisski-distillery/internal/status" "github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient" "github.com/tkw1536/goprogram/stream" ) @@ -20,7 +21,7 @@ type RunningFetcher struct { Barrel *Barrel } -func (rf *RunningFetcher) Fetch(flags ingredient.FetchFlags, info *ingredient.Information) (err error) { +func (rf *RunningFetcher) Fetch(flags ingredient.FetcherFlags, info *status.Information) (err error) { info.Running, err = rf.Barrel.Running() return } diff --git a/internal/wisski/ingredient/barrel/ssh/ssh.go b/internal/wisski/ingredient/barrel/ssh/ssh.go index 36c99a7..bd553b0 100644 --- a/internal/wisski/ingredient/barrel/ssh/ssh.go +++ b/internal/wisski/ingredient/barrel/ssh/ssh.go @@ -3,6 +3,7 @@ package ssh import ( "io" + "github.com/FAU-CDI/wisski-distillery/internal/status" "github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient" "github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/barrel" "github.com/FAU-CDI/wisski-distillery/pkg/environment" @@ -32,7 +33,7 @@ func (ssh *SSH) Keys() ([]ssh.PublicKey, error) { return sshx.ParseAllKeys(bytes), nil } -func (sshx *SSH) Fetch(flags ingredient.FetchFlags, info *ingredient.Information) error { +func (sshx *SSH) Fetch(flags ingredient.FetcherFlags, info *status.Information) error { if flags.Quick { return nil } diff --git a/internal/wisski/ingredient/fetcher.go b/internal/wisski/ingredient/fetcher.go index 2f204fc..f0b901c 100644 --- a/internal/wisski/ingredient/fetcher.go +++ b/internal/wisski/ingredient/fetcher.go @@ -1,132 +1,20 @@ package ingredient import ( - "fmt" - "time" - - "github.com/FAU-CDI/wisski-distillery/internal/models" "github.com/FAU-CDI/wisski-distillery/internal/phpx" + "github.com/FAU-CDI/wisski-distillery/internal/status" ) -// Fetcher is an ingredient with a fetch method -type Fetcher interface { +type WissKIFetcher interface { Ingredient - // Fetch fetchs information with the given information and writes it into info. - // Distinct Fetchers must write into distinct fields. - Fetch(flags FetchFlags, info *Information) error + // Fetch fetches information from this ingredient and writes it into target. + // Distinct WissKIFetchers must write into distinct fields. + Fetch(flags FetcherFlags, target *status.Information) error } -// FetchFlags specifies what information to fetch -type FetchFlags struct { +// FetcherFlags describes options for a WissKIFetcher +type FetcherFlags struct { Quick bool Server *phpx.Server } - -// Information represents fetched information about a WissKI -type Information struct { - Time time.Time // Time this info was built - - // Generic Information - Slug string // slug - URL string // complete URL, including http(s) - - Locked bool // Is this instance currently locked? - - // Information about the running instance - Running bool - LastRebuild time.Time - LastUpdate time.Time - LastCron time.Time - - // Statistics of the wisski (TODO: fix me) - Statistics Statistics - - // List of backups made - Snapshots []models.Export - - // List of SSH Keys - SSHKeys []string - - // WissKI content information - NoPrefixes bool // TODO: Move this into the database - Prefixes []string // list of prefixes - Pathbuilders map[string]string // all the pathbuilders -} - -type Statistics struct { - Activity struct { - MostVisited string `json:"mostVisited"` - PageVisits []struct { - URL string `json:"url"` - Visits int `json:"visits"` - } `json:"pageVisits"` - TotalEditsLastWeek int `json:"totalEditsLastWeek"` - } `json:"activity"` - Bundles BundleStatistics `json:"bundles"` - Triplestore struct { - Graphs []struct { - URI string `json:"uri"` - Count int `json:"triples"` - } `json:"graphStatistics"` - Total int `json:"totalTriples"` - } `json:"triplestore"` - Users struct { - LastLogin string `json:"lastLogin"` - TotalUsers int `json:"totalUsers"` - } `json:"users"` -} - -type BundleStatistics struct { - Bundles []struct { - Label string `json:"label"` - MachineName string `json:"machineName"` - - Count int `json:"entities"` - - LastEdit phpx.TimeInt `json:"lastEdit"` - - MainBundle phpx.PHPBoolean `json:"mainBundle"` - } `json:"bundleStatistics"` - TotalBundles int `json:"totalBundles"` - TotalMainBundles int `json:"totalMainBundles"` -} - -type LastEdit struct { - Time time.Time - Valid bool -} - -// LastEdit returns the last time any bundle was edited, and if any edit was bigger than the reference time -func (bs BundleStatistics) LastEdit() (le LastEdit) { - for _, bundle := range bs.Bundles { - time := bundle.LastEdit.Time() - if time.After(le.Time) { - le.Valid = true - le.Time = time - } - } - return -} - -func (bs BundleStatistics) Summary() string { - var totalCount int - for _, bundle := range bs.Bundles { - totalCount += bundle.Count - } - if totalCount == 0 { - return "" - } - - entitySubject := "Entities" - if totalCount == 1 { - entitySubject = "Entity" - } - - bundleSubject := "Bundles" - if len(bs.Bundles) == 1 { - bundleSubject = "Bundle" - } - - return fmt.Sprintf("%d %s in %d %s", totalCount, entitySubject, len(bs.Bundles), bundleSubject) -} diff --git a/internal/wisski/ingredient/info/info.go b/internal/wisski/ingredient/info/info.go index b1dc6d7..273a270 100644 --- a/internal/wisski/ingredient/info/info.go +++ b/internal/wisski/ingredient/info/info.go @@ -3,6 +3,7 @@ package info import ( "time" + "github.com/FAU-CDI/wisski-distillery/internal/status" "github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient" "github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/php" "github.com/FAU-CDI/wisski-distillery/pkg/lazy" @@ -13,16 +14,16 @@ type Info struct { ingredient.Base PHP *php.PHP - Fetchers []ingredient.Fetcher + Fetchers []ingredient.WissKIFetcher Analytics *lazy.PoolAnalytics } // Information fetches information about this WissKI. // TODO: Rework this to be able to determine what kind of information is available. -func (wisski *Info) Information(quick bool) (info ingredient.Information, err error) { +func (wisski *Info) Information(quick bool) (info status.Information, err error) { // setup flags - flags := ingredient.FetchFlags{ + flags := ingredient.FetcherFlags{ Quick: quick, } @@ -47,7 +48,7 @@ func (wisski *Info) Information(quick bool) (info ingredient.Information, err er return } -func (wisski *Info) Fetch(flags ingredient.FetchFlags, info *ingredient.Information) error { +func (wisski *Info) Fetch(flags ingredient.FetcherFlags, info *status.Information) error { info.Time = time.Now().UTC() info.Slug = wisski.Slug info.URL = wisski.URL().String() diff --git a/internal/wisski/ingredient/info/snapshots.go b/internal/wisski/ingredient/info/snapshots.go index b9ab477..4db62d7 100644 --- a/internal/wisski/ingredient/info/snapshots.go +++ b/internal/wisski/ingredient/info/snapshots.go @@ -1,6 +1,9 @@ package info -import "github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient" +import ( + "github.com/FAU-CDI/wisski-distillery/internal/status" + "github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient" +) type SnapshotsFetcher struct { ingredient.Base @@ -8,7 +11,7 @@ type SnapshotsFetcher struct { Info *Info } -func (lbr *SnapshotsFetcher) Fetch(flags ingredient.FetchFlags, info *ingredient.Information) (err error) { +func (lbr *SnapshotsFetcher) Fetch(flags ingredient.FetcherFlags, info *status.Information) (err error) { if flags.Quick { return } diff --git a/internal/wisski/ingredient/locker/locked.go b/internal/wisski/ingredient/locker/locked.go index a6a39b5..dcc234b 100644 --- a/internal/wisski/ingredient/locker/locked.go +++ b/internal/wisski/ingredient/locker/locked.go @@ -2,6 +2,7 @@ package locker import ( "github.com/FAU-CDI/wisski-distillery/internal/models" + "github.com/FAU-CDI/wisski-distillery/internal/status" "github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient" ) @@ -17,7 +18,7 @@ func (lock *Locker) Locked() (locked bool) { return } -func (locker *Locker) Fetch(flags ingredient.FetchFlags, info *ingredient.Information) (err error) { +func (locker *Locker) Fetch(flags ingredient.FetcherFlags, info *status.Information) (err error) { info.Locked = locker.Locked() return } diff --git a/internal/wisski/ingredient/php/extras/pathbuilder.go b/internal/wisski/ingredient/php/extras/pathbuilder.go index 8051e20..afe0a35 100644 --- a/internal/wisski/ingredient/php/extras/pathbuilder.go +++ b/internal/wisski/ingredient/php/extras/pathbuilder.go @@ -4,6 +4,7 @@ import ( _ "embed" "github.com/FAU-CDI/wisski-distillery/internal/phpx" + "github.com/FAU-CDI/wisski-distillery/internal/status" "github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient" "github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/php" "golang.org/x/exp/slices" @@ -44,7 +45,7 @@ func (pathbuilder *Pathbuilder) GetAll(server *phpx.Server) (pathbuilders map[st return } -func (pathbuilder *Pathbuilder) Fetch(flags ingredient.FetchFlags, info *ingredient.Information) (err error) { +func (pathbuilder *Pathbuilder) Fetch(flags ingredient.FetcherFlags, info *status.Information) (err error) { if flags.Quick { return } diff --git a/internal/wisski/ingredient/php/extras/prefixes.go b/internal/wisski/ingredient/php/extras/prefixes.go index 33608a3..9705d4a 100644 --- a/internal/wisski/ingredient/php/extras/prefixes.go +++ b/internal/wisski/ingredient/php/extras/prefixes.go @@ -6,6 +6,7 @@ import ( "strings" "github.com/FAU-CDI/wisski-distillery/internal/phpx" + "github.com/FAU-CDI/wisski-distillery/internal/status" "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/internal/wisski/ingredient/php" @@ -155,7 +156,7 @@ func (wisski *Prefixes) Update() error { return prefix.SetAll(wisski.MStore, prefixes...) } -func (prefixes *Prefixes) Fetch(flags ingredient.FetchFlags, info *ingredient.Information) (err error) { +func (prefixes *Prefixes) Fetch(flags ingredient.FetcherFlags, info *status.Information) (err error) { info.NoPrefixes = prefixes.NoPrefix() if flags.Quick { // quick mode: grab only the cached prefixes diff --git a/internal/wisski/ingredient/php/extras/stats.go b/internal/wisski/ingredient/php/extras/stats.go index 047ac4e..13e2598 100644 --- a/internal/wisski/ingredient/php/extras/stats.go +++ b/internal/wisski/ingredient/php/extras/stats.go @@ -5,6 +5,7 @@ import ( "log" "github.com/FAU-CDI/wisski-distillery/internal/phpx" + "github.com/FAU-CDI/wisski-distillery/internal/status" "github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient" "github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/php" ) @@ -19,7 +20,7 @@ type Stats struct { var statsPHP string // Get fetches all statistics from the server -func (stats *Stats) Get(server *phpx.Server) (data ingredient.Statistics, err error) { +func (stats *Stats) Get(server *phpx.Server) (data status.Statistics, err error) { err = stats.PHP.ExecScript(server, &data, statsPHP, "export_statistics") if err != nil { log.Println(err) @@ -27,7 +28,7 @@ func (stats *Stats) Get(server *phpx.Server) (data ingredient.Statistics, err er return } -func (stats *Stats) Fetch(flags ingredient.FetchFlags, info *ingredient.Information) (err error) { +func (stats *Stats) Fetch(flags ingredient.FetcherFlags, info *status.Information) (err error) { if flags.Quick { return } diff --git a/pkg/lazy/pool.go b/pkg/lazy/pool.go index d647f7a..97740e2 100644 --- a/pkg/lazy/pool.go +++ b/pkg/lazy/pool.go @@ -171,6 +171,5 @@ func ExportComponent[Component any, InitParams any, ConcreteComponentType any]( } } - var component ConcreteComponentType - return component + panic("ExportComponent: Attempted to export unregistered component") }