mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-24 04:46:19 -06:00
remove tryUntil
This commit is contained in:
parent
4580ae194c
commit
be85a5b642
7 changed files with 30 additions and 43 deletions
26
internal/cache/cache.go
vendored
26
internal/cache/cache.go
vendored
|
|
@ -23,6 +23,7 @@ import (
|
|||
"codeberg.org/gruf/go-cache/v3/ttl"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/cache/headerfilter"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/log"
|
||||
)
|
||||
|
||||
|
|
@ -124,23 +125,18 @@ func (c *Caches) Init() {
|
|||
|
||||
// Start will start any caches that require a background
|
||||
// routine, which usually means any kind of TTL caches.
|
||||
func (c *Caches) Start() {
|
||||
func (c *Caches) Start() error {
|
||||
log.Infof(nil, "start: %p", c)
|
||||
|
||||
tryUntil("starting webfinger cache", 5, func() bool {
|
||||
return c.Webfinger.Start(5 * time.Minute)
|
||||
})
|
||||
if !c.Webfinger.Start(5 * time.Minute) {
|
||||
return gtserror.New("could not start webfinger cache")
|
||||
}
|
||||
|
||||
tryUntil("starting statusesFilterableFields cache", 5, func() bool {
|
||||
return c.StatusesFilterableFields.Start(5 * time.Minute)
|
||||
})
|
||||
}
|
||||
if !c.StatusesFilterableFields.Start(5 * time.Minute) {
|
||||
return gtserror.New("could not start statusesFilterableFields cache")
|
||||
}
|
||||
|
||||
// Inited returns true if the
|
||||
// caches have been initialized.
|
||||
func (c *Caches) Inited() bool {
|
||||
// Use nilness of *ttl.Cache pointers as heuristic.
|
||||
return c.Webfinger != nil && c.StatusesFilterableFields != nil
|
||||
return nil
|
||||
}
|
||||
|
||||
// Stop will stop any caches that require a background
|
||||
|
|
@ -148,8 +144,8 @@ func (c *Caches) Inited() bool {
|
|||
func (c *Caches) Stop() {
|
||||
log.Infof(nil, "stop: %p", c)
|
||||
|
||||
tryUntil("stopping webfinger cache", 5, c.Webfinger.Stop)
|
||||
tryUntil("stopping statusesFilterableFields cache", 5, c.StatusesFilterableFields.Stop)
|
||||
_ = c.Webfinger.Stop()
|
||||
_ = c.StatusesFilterableFields.Stop()
|
||||
}
|
||||
|
||||
// Sweep will sweep all the available caches to ensure none
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue