exec

package
v0.0.0-...-012d1c6 Latest Latest
Warning

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

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

README

executor

线程模型:常见的线程模型

  • 单线程
  • 线程池
  • Hash到某个固定线程

接口定义应该更简单通用,使用场景上,通常用于rpc消息回调,数据库请求回调,MQ消息回调等一些异步操作

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAlreadyStop = errors.New("already stop")
)

Functions

func SetDefault

func SetDefault(e Executor)

Types

type Executor

type Executor interface {
	Post(task Task) error
	Stop() error
	Wait()
}

线程/协程模型

	1:单线程
	2:根据ID hash到某个线程
	3:线程池,不超过最大线程数
 4:每个消息起一个go routine?

TODO:消息延迟处理或重新投递 比如收到消息后,需要先验证数据是否加载成功

func Default

func Default() Executor

type Task

type Task interface {
	Run() error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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