timer

package
v3.28.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package timer contains a service to store and manage timers in a database

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

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

Service implements a timer service

func New

func New(db database.Connector, cronService *cron.Cron) (*Service, error)

New creates a new Service

func (Service) AddCooldown

func (s Service) AddCooldown(tt plugins.TimerType, limiter, ruleID string, expiry time.Time) error

AddCooldown adds a new cooldown timer

func (Service) AddPermit

func (s Service) AddPermit(channel, username string) error

AddPermit adds a new permit timer

func (*Service) CopyDatabase added in v3.20.0

func (*Service) CopyDatabase(src, target *gorm.DB) error

CopyDatabase enables the service to migrate to a new database

func (Service) HasPermit

func (s Service) HasPermit(channel, username string) (bool, error)

HasPermit checks whether a valid permit is present

func (Service) HasTimer

func (s Service) HasTimer(id string) (bool, error)

HasTimer checks whether a timer with given ID is present

func (Service) InCooldown

func (s Service) InCooldown(tt plugins.TimerType, limiter, ruleID string) (bool, error)

InCooldown checks whether the cooldown has expired

func (Service) SetTimer

func (s Service) SetTimer(id string, expiry time.Time) error

SetTimer sets a timer with given ID and expiry

func (*Service) UpdatePermitTimeout

func (s *Service) UpdatePermitTimeout(d time.Duration)

UpdatePermitTimeout sets a new permit timeout for future permits

Jump to

Keyboard shortcuts

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