slackbot_cleanup

package
v1.303.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CleanupWorker

type CleanupWorker struct {
	// contains filtered or unexported fields
}

CleanupWorker periodically deletes Slackbot sessions whose last message is older than SessionTTL. It uses the agentapi.proxy/slack-last-message-at annotation to determine when the last message occurred.

func NewCleanupWorker

func NewCleanupWorker(
	sessionManager portrepos.SessionManager,
	k8sClient kubernetes.Interface,
	namespace string,
	config CleanupWorkerConfig,
) *CleanupWorker

NewCleanupWorker creates a new CleanupWorker.

func (*CleanupWorker) Start

func (w *CleanupWorker) Start(ctx context.Context) error

Start begins the cleanup worker loop. It is safe to call from multiple goroutines.

func (*CleanupWorker) Stop

func (w *CleanupWorker) Stop()

Stop gracefully stops the worker.

type CleanupWorkerConfig

type CleanupWorkerConfig struct {
	// CheckInterval is how often the worker scans for stale sessions.
	// Default: 1h
	CheckInterval time.Duration
	// SessionTTL is the duration after the last message before a session is deleted.
	// Default: 72h (3 days)
	SessionTTL time.Duration
	// Enabled controls whether the worker actually runs.
	Enabled bool
	// DryRun disables actual session deletion; stale sessions are only logged.
	// Useful for verifying TTL settings before enabling real cleanup.
	// Default: false
	DryRun bool
}

CleanupWorkerConfig holds configuration for the Slackbot session cleanup worker.

func DefaultCleanupWorkerConfig

func DefaultCleanupWorkerConfig() CleanupWorkerConfig

DefaultCleanupWorkerConfig returns the default configuration.

type LeaderCleanupWorker

type LeaderCleanupWorker struct {
	// contains filtered or unexported fields
}

LeaderCleanupWorker combines leader election with the Slackbot cleanup worker. Only the elected leader runs the cleanup loop, preventing duplicate deletions in multi-replica deployments.

func NewLeaderCleanupWorker

func NewLeaderCleanupWorker(
	sessionManager portrepos.SessionManager,
	k8sClient kubernetes.Interface,
	namespace string,
	workerConfig CleanupWorkerConfig,
	electionConfig schedule.LeaderElectionConfig,
) *LeaderCleanupWorker

NewLeaderCleanupWorker creates a new LeaderCleanupWorker.

func (*LeaderCleanupWorker) Run

func (lw *LeaderCleanupWorker) Run(ctx context.Context)

Run starts the leader election loop. Only the leader runs the cleanup worker.

func (*LeaderCleanupWorker) Stop

func (lw *LeaderCleanupWorker) Stop()

Stop gracefully stops the leader cleanup worker.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL