Add a metadata system
This commit is contained in:
parent
07409a01be
commit
8b3218ad00
16 changed files with 365 additions and 61 deletions
|
|
@ -1,6 +1,9 @@
|
|||
package instances
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/tkw1536/goprogram/stream"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
|
@ -10,12 +13,15 @@ type Info struct {
|
|||
Slug string // The slug of the instance
|
||||
URL string // The public URL of this instance
|
||||
|
||||
LastRebuild time.Time
|
||||
|
||||
Running bool // is the instance running?
|
||||
Pathbuilders []string // list of pathbuilders
|
||||
}
|
||||
|
||||
// Info returns information about this WissKI instance.
|
||||
func (wisski *WissKI) Info(quick bool) (info Info, err error) {
|
||||
fmt.Println("call to info")
|
||||
// static properties
|
||||
info.Slug = wisski.Slug
|
||||
info.URL = wisski.URL().String()
|
||||
|
|
@ -30,15 +36,20 @@ func (wisski *WissKI) Info(quick bool) (info Info, err error) {
|
|||
})
|
||||
|
||||
// slower checks for extra properties.
|
||||
// these execute php code
|
||||
// these might execute php code or require additional database queries.
|
||||
if !quick {
|
||||
group.Go(func() error {
|
||||
info.Pathbuilders, _ = wisski.Pathbuilders()
|
||||
return nil
|
||||
})
|
||||
group.Go(func() (err error) {
|
||||
info.Pathbuilders, err = wisski.Pathbuilders()
|
||||
return
|
||||
info.LastRebuild, _ = wisski.LastRebuild()
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
err = group.Wait()
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue