Documentation
¶
Overview ¶
Package appsleep stops opted-in apps that have had no requests for a while and wakes them on the next request, so idle apps cost no memory or CPU.
Index ¶
Constants ¶
View Source
const DefaultInterval = time.Minute
DefaultInterval is how often idle apps are looked for.
Variables ¶
This section is empty.
Functions ¶
func Wake ¶
func Wake(ctx context.Context, sleep interface { SetAppSleeping(ctx context.Context, serviceName string, sleeping bool, now time.Time) error GetAppSleep(ctx context.Context, serviceName string) (store.AppSleep, error) }, apps Apps, nudger Nudger, name string, now time.Time) (bool, error)
Wake starts a sleeping app and resets its idle clock. It reports whether the app was actually asleep, so repeated wake requests are harmless.
Types ¶
type Apps ¶
type Apps interface {
GetDesiredService(ctx context.Context, name string) (*store.DesiredService, error)
UpdateServiceSuspended(ctx context.Context, name string, suspended bool) error
}
Apps is the slice of the app store the scheduler needs.
type Scheduler ¶
type Scheduler struct {
Sleep SleepStore
Apps Apps
Traffic Traffic
Nudger Nudger
Logger *slog.Logger
Now func() time.Time
}
Scheduler puts idle opted-in apps to sleep.
Click to show internal directories.
Click to hide internal directories.