2021-09-23 11:05:51 +08:00
|
|
|
package event
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
)
|
|
|
|
|
|
|
|
type eventType int8
|
|
|
|
|
|
|
|
const (
|
2021-09-28 20:55:09 +08:00
|
|
|
defaultEventState = eventType(iota) //默认情况下的状态
|
|
|
|
waitEventState // 等待状态
|
|
|
|
workEventState //工作状态
|
|
|
|
closeEventState //事件关闭状态
|
2021-09-23 11:05:51 +08:00
|
|
|
)
|
|
|
|
|
2021-09-28 20:55:09 +08:00
|
|
|
type EventWorkFunc func() (interface{}, error)
|
|
|
|
|
2021-09-23 11:05:51 +08:00
|
|
|
type DriverInterface interface {
|
|
|
|
Get() *Event
|
|
|
|
Put(event *Event)
|
2021-10-09 22:05:39 +08:00
|
|
|
GetLength() int
|
2021-09-23 11:05:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type ProduceInterface interface {
|
|
|
|
Call(ctx context.Context, event *Event)
|
|
|
|
}
|
|
|
|
|
|
|
|
type ConsumerInterface interface {
|
|
|
|
Receive(ctx context.Context) *Event
|
|
|
|
}
|
2021-09-27 11:29:47 +08:00
|
|
|
|