2021-09-23 11:05:51 +08:00
|
|
|
package event
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2021-10-26 14:39:34 +08:00
|
|
|
defaultEventState = int32(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 {
|
2021-10-26 09:29:39 +08:00
|
|
|
Get() *event
|
|
|
|
Put(*event)
|
2021-10-09 22:05:39 +08:00
|
|
|
GetLength() int
|
2021-10-26 09:29:39 +08:00
|
|
|
NewEvent(string) *event
|
|
|
|
Recovery(*event)
|
2021-09-23 11:05:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type ProduceInterface interface {
|
2021-10-26 09:29:39 +08:00
|
|
|
Call(context.Context, *event)
|
|
|
|
NewEvent(string) *event
|
|
|
|
Recovery(*event)
|
2021-09-23 11:05:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type ConsumerInterface interface {
|
2021-10-26 09:29:39 +08:00
|
|
|
Receive(ctx context.Context) *event
|
|
|
|
Recovery(*event)
|
2021-09-23 11:05:51 +08:00
|
|
|
}
|