Documentation
¶
Index ¶
- func ActivityBumpWorkspace(ctx context.Context, log slog.Logger, db database.Store, workspaceID uuid.UUID, ...)
- func UpdateTemplateWorkspacesLastUsedAt(ctx context.Context, db database.Store, templateID uuid.UUID, ...) error
- type Reporter
- type ReporterOptions
- type StatsBatcher
- type UpdateTemplateWorkspacesLastUsedAtFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActivityBumpWorkspace ¶
func ActivityBumpWorkspace(ctx context.Context, log slog.Logger, db database.Store, workspaceID uuid.UUID, nextAutostart time.Time)
ActivityBumpWorkspace automatically bumps the workspace's auto-off timer if it is set to expire soon. The deadline will be bumped by 1 hour*. If the bump crosses over an autostart time, the workspace will be bumped by the workspace ttl instead.
If nextAutostart is the zero value or in the past, the workspace will be bumped by 1 hour. It handles the edge case in the example:
- Autostart is set to 9am.
- User works all day, and leaves a terminal open to the workspace overnight.
- The open terminal continually bumps the workspace deadline.
- 9am the next day, the activity bump pushes to 10am.
- If the user goes inactive for 1 hour during the day, the workspace will now stop, because it has been extended by 1 hour durations. Despite the TTL being set to 8hrs from the autostart time.
So the issue is that when the workspace is bumped across an autostart deadline, we should treat the workspace as being "started" again and extend the deadline by the autostart time + workspace ttl instead.
The issue still remains with build_max_deadline. We need to respect the original maximum deadline, so that will need to be handled separately. A way to avoid this is to configure the max deadline to something that will not span more than 1 day. This will force the workspace to restart and reset the deadline each morning when it autostarts.
Types ¶
type Reporter ¶
type Reporter struct {
// contains filtered or unexported fields
}
func NewReporter ¶
func NewReporter(opts ReporterOptions) *Reporter
func (*Reporter) ReportAgentStats ¶
func (*Reporter) ReportAppStats ¶
func (r *Reporter) ReportAppStats(ctx context.Context, stats []workspaceapps.StatsReport) error
type ReporterOptions ¶
type ReporterOptions struct { Database database.Store Logger slog.Logger Pubsub pubsub.Pubsub TemplateScheduleStore *atomic.Pointer[schedule.TemplateScheduleStore] StatsBatcher StatsBatcher UpdateAgentMetricsFn func(ctx context.Context, labels prometheusmetrics.AgentMetricLabels, metrics []*agentproto.Stats_Metric) AppStatBatchSize int }