remove tryUntil

This commit is contained in:
tobi 2025-03-05 17:07:56 +01:00
commit be85a5b642
7 changed files with 30 additions and 43 deletions

View file

@ -38,7 +38,9 @@ import (
func initState(ctx context.Context) (*state.State, error) {
var state state.State
state.Caches.Init()
state.Caches.Start()
if err := state.Caches.Start(); err != nil {
return nil, fmt.Errorf("error starting caches: %w", err)
}
// Only set state DB connection.
// Don't need Actions or Workers for this (yet).

View file

@ -125,7 +125,9 @@ func setupList(ctx context.Context) (*list, error) {
}
state.Caches.Init()
state.Caches.Start()
if err := state.Caches.Start(); err != nil {
return nil, fmt.Errorf("error starting caches: %w", err)
}
// Only set state DB connection.
// Don't need Actions or Workers for this.

View file

@ -42,7 +42,9 @@ func setupPrune(ctx context.Context) (*prune, error) {
var state state.State
state.Caches.Init()
state.Caches.Start()
if err := state.Caches.Start(); err != nil {
return nil, fmt.Errorf("error starting caches: %w", err)
}
// Scheduler is required for the
// cleaner, but no other workers

View file

@ -118,11 +118,10 @@ var Start action.GTSAction = func(ctx context.Context) error {
)
defer func() {
if state.Caches.Inited() {
// We reached a point where caches
// were initialized. Stop them.
state.Caches.Stop()
}
// Stop any started caches.
//
// Noop if never started.
state.Caches.Stop()
if route != nil {
// We reached a point where the API router
@ -207,7 +206,9 @@ var Start action.GTSAction = func(ctx context.Context) error {
// Initialize caches
state.Caches.Init()
state.Caches.Start()
if err := state.Caches.Start(); err != nil {
return fmt.Errorf("error starting caches: %w", err)
}
// Open connection to the database now caches started.
dbService, err := bundb.NewBunDBService(ctx, state)