event

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package event @Title 事件类型 @Description 事件类型 @Author yr 2024/7/19 下午3:40 @Update yr 2024/7/19 下午3:40

Package event @Title 事件处理器 @Description 用于给事件一个注册绑定,标注这个事件在哪里注册过 @Author yr 2024/7/19 下午3:31 @Update yr 2024/7/19 下午3:31

Package event @Title 事件处理器接口 @Description 事件处理器接口 @Author yr 2024/7/19 下午3:19 @Update yr 2024/7/19 下午3:19

Package event @Title 事件管理器 @Description 这里管理着所有已经注册的事件,一般是一个service一个processor,事件触发时分发到不同的handler,并执行回调 @Author yr 2024/7/19 下午3:33 @Update yr 2024/7/19 下午3:33

Index

Constants

View Source
const (

	// 基础事件 -1000以上 系统事件 -1 到 -999  用户事件 1 - 99
	SysEventWebsocket = -5

	SysEventRpc        = -1001 // 远程调用事件
	SysEventReply      = -1002 // 远程调用回复事件
	SysEventClientMsg  = -1003 // 客户端消息事件
	SysEventETCDPut    = -1004 // etcd 存储事件
	SysEventETCDDel    = -1005 // etcd 删除事件
	SysEventServiceReg = -1006 // 服务注册事件
	SysEventServiceDis = -1007 // 服务注销事件

	SysEventNodeConn = -1010 // 节点连接事件
	SysEventNatsConn = -1011 // nats 连接事件

	MaxType = -1000
)

Variables

This section is empty.

Functions

func ReleaseEvent

func ReleaseEvent(e *Event)

Types

type CallBack

type CallBack func(event IEvent)

CallBack 事件接受器

type Event

type Event struct {
	def.DataRef
	Type def.EventType
	Data interface{}
	// contains filtered or unexported fields
}

func NewEvent

func NewEvent() *Event

func (*Event) GetType

func (e *Event) GetType() def.EventType

func (*Event) Reset

func (e *Event) Reset()

type EventCallBack

type EventCallBack func(event inf.IEvent)

事件接受器

type EventHandler

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

func (*EventHandler) Destroy

func (handler *EventHandler) Destroy()

func (*EventHandler) GetEventProcessor

func (handler *EventHandler) GetEventProcessor() IEventProcessor

func (*EventHandler) Init

func (handler *EventHandler) Init(processor IEventProcessor)

func (*EventHandler) NotifyEvent

func (handler *EventHandler) NotifyEvent(ev inf.IEvent)

type EventProcessor

type EventProcessor struct {
	IEventChannel
	// contains filtered or unexported fields
}

func (*EventProcessor) EventHandler

func (processor *EventProcessor) EventHandler(ev inf.IEvent)

func (*EventProcessor) Init

func (processor *EventProcessor) Init(eventChannel IEventChannel)

func (*EventProcessor) RegEventReceiverFunc

func (processor *EventProcessor) RegEventReceiverFunc(eventType def.EventType, receiver IEventHandler, callback EventCallBack)

func (*EventProcessor) UnRegEventReceiverFun

func (processor *EventProcessor) UnRegEventReceiverFun(eventType def.EventType, receiver IEventHandler)

type EventType

type EventType int

type Handler

type Handler struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*Handler) Destroy

func (h *Handler) Destroy()

func (*Handler) GetEventProcessor

func (h *Handler) GetEventProcessor() IProcessor

func (*Handler) Init

func (h *Handler) Init(p IProcessor)

func (*Handler) NotifyEvent

func (h *Handler) NotifyEvent(ev IEvent)

type IChannel

type IChannel interface {
	PushEvent(ev IEvent) error
}

type IEventChannel

type IEventChannel interface {
	PushEvent(ev inf.IEvent) error
}

type IEventHandler

type IEventHandler interface {
	Init(processor IEventProcessor)
	GetEventProcessor() IEventProcessor //获得事件
	NotifyEvent(inf.IEvent)
	Destroy()
	// contains filtered or unexported methods
}

func NewEventHandler

func NewEventHandler() IEventHandler

type IEventProcessor

type IEventProcessor interface {
	IEventChannel

	Init(eventChannel IEventChannel)
	EventHandler(ev inf.IEvent)
	RegEventReceiverFunc(eventType def.EventType, receiver IEventHandler, callback EventCallBack)
	UnRegEventReceiverFun(eventType def.EventType, receiver IEventHandler)
	// contains filtered or unexported methods
}

func NewEventProcessor

func NewEventProcessor() IEventProcessor

type IHandler

type IHandler interface {
	Init(p IProcessor)
	GetEventProcessor() IProcessor
	NotifyEvent(IEvent)
	Destroy()
	// contains filtered or unexported methods
}

func NewHandler

func NewHandler() IHandler

type IProcessor

type IProcessor interface {
	IChannel

	Init(eventChannel IChannel)
	EventHandler(ev IEvent)
	RegEventReceiverFunc(eventType int, receiver IHandler, callback CallBack)
	UnRegEventReceiverFun(eventType int, receiver IHandler)
	// contains filtered or unexported methods
}

func NewProcessor

func NewProcessor() IProcessor

type Processor

type Processor struct {
	IChannel
	// contains filtered or unexported fields
}

func (*Processor) EventHandler

func (p *Processor) EventHandler(ev IEvent)

EventHandler 事件处理

func (*Processor) Init

func (p *Processor) Init(eventChannel IChannel)

func (*Processor) RegEventReceiverFunc

func (p *Processor) RegEventReceiverFunc(eventType int, receiver IHandler, callback CallBack)

RegEventReceiverFunc 注册事件处理函数

func (*Processor) UnRegEventReceiverFun

func (p *Processor) UnRegEventReceiverFun(eventType int, receiver IHandler)

UnRegEventReceiverFun 取消注册

Jump to

Keyboard shortcuts

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