period_job

package
v0.0.0-...-3caf815 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2021 License: MIT Imports: 5 Imported by: 1

Documentation

Overview

* Package period_job 实现了周期性任务的定时触发执行。

manager := period_job.NewManager(ctx, cc)

job1 := &DemoJob{}
job2 := &DemoJob{}

manager.Run("Test", job1, 10*time.Millisecond)
manager.Run("Test2", job2, 20*time.Millisecond)

manager.Wait()

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job interface {
	Handle()
}

Job is a interface for a job

type Manager

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

Manager 周期性任务管理器

func NewManager

func NewManager(ctx context.Context, cc container.Container) *Manager

NewManager 创建一个Manager

func (*Manager) Pause

func (jm *Manager) Pause(name string, pause bool)

func (*Manager) Paused

func (jm *Manager) Paused(name string) bool

Paused return whether the named job has been paused

func (*Manager) Run

func (jm *Manager) Run(name string, job Job, interval time.Duration)

Run 启动周期性任务循环

func (*Manager) Wait

func (jm *Manager) Wait()

Wait 等待所有任务结束

Jump to

Keyboard shortcuts

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