cron

package
Version: v3.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2017 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPlugin

func NewPlugin(cron CronContext) plugins.BotMessagePlugin

Types

type ActionType

type ActionType string
const (
	AddAction       ActionType = "add"
	RandomAddAction ActionType = "random"
	DelAction       ActionType = "del"
	DeleteAction    ActionType = "delete"
	StopAction      ActionType = "stop"
	ListAction      ActionType = "list"
	RefreshAction   ActionType = "refresh"
	HelpAction      ActionType = "help"
)

type CronCommand

type CronCommand struct {
	Trigger  string // cron
	Action   ActionType
	CronSpec string
	Args     []string
	CronID   string
}

func (CronCommand) CronKey

func (c CronCommand) CronKey() string

func (CronCommand) Message

func (c CronCommand) Message() string

func (*CronCommand) Scan

func (c *CronCommand) Scan(command string) error

Scan cron add */1 * * * * * hogehoge -> cronCommand

func (CronCommand) String

func (c CronCommand) String() string

type CronContext

type CronContext interface {
	AddCronCommand(channel string, c CronCommand) string
	DelCronCommand(channel string, c CronCommand) string
	ListCronCommand(channel string, c CronCommand) string
	HelpCronCommand(channel string, c CronCommand) string
	RefreshCron(messageSender plugins.MessageSender, channel string)
	AllRefreshCron(messageSender plugins.MessageSender)
	Close()
}

func NewCronContext

func NewCronContext(repository CronRepository) CronContext

type CronRepository

type CronRepository interface {
	Load() (map[string]CronTaskMap, error)
	Save(cronTaskMap map[string]CronTaskMap) error
	Close() error
}

func NewOnMemoryCronRepository

func NewOnMemoryCronRepository() CronRepository

func NewRedisRepository

func NewRedisRepository(addr, password string, db int64) CronRepository

type CronTask

type CronTask struct {
	Active  bool
	Command CronCommand
}

type CronTaskMap

type CronTaskMap map[string]CronTask

func (CronTaskMap) AddTask

func (c CronTaskMap) AddTask(key string, task CronTask)

type OnMemoryCronRepository

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

func (OnMemoryCronRepository) Close

func (r OnMemoryCronRepository) Close() error

func (OnMemoryCronRepository) Load

func (OnMemoryCronRepository) Save

func (r OnMemoryCronRepository) Save(cronTaskMap map[string]CronTaskMap) error

type RedisRepository

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

func (RedisRepository) Close

func (s RedisRepository) Close() error

func (RedisRepository) Load

func (s RedisRepository) Load() (map[string]CronTaskMap, error)

func (RedisRepository) Save

func (s RedisRepository) Save(taskMap map[string]CronTaskMap) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL