facade.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package mhayaActor
  2. import (
  3. "time"
  4. creflect "github.com/mhaya/extend/reflect"
  5. cfacade "github.com/mhaya/facade"
  6. )
  7. type (
  8. IActorLoader interface {
  9. load(actor Actor)
  10. }
  11. )
  12. type (
  13. IEvent interface {
  14. Register(name string, fn IEventFunc) // 注册事件
  15. Registers(names []string, fn IEventFunc) // 注册多个事件
  16. Unregister(name string) // 注销事件
  17. }
  18. IEventFunc func(cfacade.IEventData) // 接收事件数据时的处理函数
  19. )
  20. type (
  21. IMailBox interface {
  22. Register(funcName string, fn interface{}) // 注册执行函数
  23. GetFuncInfo(funcName string) (*creflect.FuncInfo, bool)
  24. }
  25. )
  26. type (
  27. ITimer interface {
  28. Add(d time.Duration, fn func(), async ...bool) uint64 // 添加定时器,循环执行
  29. AddOnce(d time.Duration, fn func(), async ...bool) uint64 // 添加定时器,执行一次
  30. AddFixedHour(hour, minute, second int, fn func(), async ...bool) uint64 // 固定x小时x分x秒,循环执行
  31. AddFixedMinute(minute, second int, fn func(), async ...bool) uint64 // 固定x分x秒,循环执行
  32. AddSchedule(s ITimerSchedule, f func(), async ...bool) uint64 // 添加自定义调度
  33. Remove(id uint64) // 移除定时器
  34. RemoveAll() // 移除所有定时器
  35. }
  36. ITimerSchedule interface {
  37. Next(time.Time) time.Time
  38. }
  39. )