job

package
v0.0.0-...-83f560d Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JobQueue chan Job

A buffered channel that we can send work requests on.

Functions

This section is empty.

Types

type Dispatcher

type Dispatcher struct {
	// A pool of workers channels that are registered with the dispatcher
	MaxWorkers int
	WorkerPool chan chan Job
}

func NewDispatcher

func NewDispatcher(maxWorkers int) *Dispatcher

func (*Dispatcher) Run

func (d *Dispatcher) Run()

type Job

type Job struct {
	Player Player
}

Job represents the job to be run

type Message

type Message struct {
	OpenID      string
	ReqID       string
	TemplateID  string
	Page        string
	Key1        string
	Value1      string
	Key2        string
	Value2      string
	Key3        string
	Value3      string
	Key4        string
	Value4      string
	Key5        string
	Value5      string
	AccessToken string
}

Message struct 小程序订阅消息推送

func (*Message) Run

func (msg *Message) Run()

Run Player.Run 小程序模板消息推送最多5个参数

type Player

type Player interface {
	Run()
}

Player 任务接口

type PlayerDemo

type PlayerDemo struct {
	OpenID string
	Text   string
}

PlayerDemo struct 示例结构

func (*PlayerDemo) Run

func (p *PlayerDemo) Run()

Run Player.Run

type Template

type Template struct {
	OpenID              string
	ReqID               string
	TemplateID          string
	PageURL             string
	MiniprogramAppID    string
	MiniprogramPagePath string
	ClientMSGID         string
	Key1                string
	Value1              string
	Color1              string
	Key2                string
	Value2              string
	Color2              string
	Key3                string
	Value3              string
	Color3              string
	Key4                string
	Value4              string
	Color4              string
	Key5                string
	Value5              string
	Color5              string
	AccessToken         string
}

Template struct 服务号模板消息推送

func (*Template) Run

func (msg *Template) Run()

Run Player.Run 服务号模板消息推送最多5个参数

type Worker

type Worker struct {
	WorkerPool chan chan Job
	JobChannel chan Job
	// contains filtered or unexported fields
}

Worker represents the worker that executes the job

func NewWorker

func NewWorker(workerPool chan chan Job) Worker

func (Worker) Start

func (w Worker) Start()

Start method starts the run loop for the worker, listening for a quit channel in case we need to stop it

func (Worker) Stop

func (w Worker) Stop()

Stop signals the worker to stop listening for work requests.

Jump to

Keyboard shortcuts

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