Documentation
¶
Overview ¶
Package cleaner contains handler to clean completed task N time ago.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var HandlerCleanerTask = "_cleaner"
HandlerCleanerTask name of the cleaner task name.
Functions ¶
This section is empty.
Types ¶
type Cleaner ¶
Cleaner contains clean handler and self repeated callback.
func New ¶
func New( ctx context.Context, errLog io.Writer, st Storage, tm *tmanager.TaskManager, config *Config, ) (*Cleaner, error)
New creates new cleaner task in the task manager and returns Cleaner with logger and config. Feel free to pass nil in config.
func (*Cleaner) CallbackTask ¶
CallbackTask self repeated callback.
func (*Cleaner) HandleTask ¶
HandleTask calls storage method to clean completed task older then config param.
type Config ¶
type Config struct {
// OlderThen task should be older than this parameter to be deleted.
OlderThen time.Duration
// CleanTasksPeriod cleaner of the old completed tasks will run every specified time period.
CleanTasksPeriod time.Duration
// HandlerNames names of the handler to be deleted.
// If empty then cleaner will delete all old tasks.
HandlerNames []string
}
Config configuration of the cleaner tasks.
type Storage ¶
type Storage interface {
// DeleteCompletedTasks delete completed tasks older then olderThen param.
DeleteCompletedTasks(ctx context.Context, olderThen time.Time) error
// DeleteNamedCompletedTasks delete completed tasks with special handler names
// and completed before olderThen param.
DeleteNamedCompletedTasks(ctx context.Context, olderThen time.Time, names ...string) error
}
Storage of the task with old tasks.
Click to show internal directories.
Click to hide internal directories.