fox/service/iservice.go
2025-05-25 20:02:15 +08:00

36 lines
726 B
Go

package service
import (
"time"
)
type IService interface {
Name() string
Type() string
RunOnce(cb func())
RunWait(cb func() (retValue any)) (retValue any, err error)
NewTimer(duration time.Duration, cb func(), needLog bool, desc ...string) uint32
CancelTimer(timerId uint32)
CancelAllTimer()
// 向服务内部消息管道写入消息
Write(msg []byte) error
Send(topic string, msg []byte) error
Call(topic string, timeout time.Duration, msg []byte) ([]byte, error)
WaitStop()
NotifyStop()
}
type ISender interface {
Send(topic string, msg []byte) error
Call(topic string, timeout time.Duration, msg []byte) ([]byte, error)
}
type IOnFunc interface {
OnStop()
OnInit()
OnMessage(msg []byte) error
}