mirror of
https://github.com/Monibuca/engine.git
synced 2025-10-05 08:36:56 +08:00
feat: add a state
This commit is contained in:
@@ -16,6 +16,7 @@ var znomorereconnect = zap.String("reason", "no more reconnect")
|
||||
type IPuller interface {
|
||||
IPublisher
|
||||
Connect() error
|
||||
OnConnected()
|
||||
Disconnect()
|
||||
Pull() error
|
||||
Reconnect() bool
|
||||
@@ -28,6 +29,10 @@ type Puller struct {
|
||||
ClientIO[config.Pull]
|
||||
}
|
||||
|
||||
func (pub *Puller) OnConnected() {
|
||||
pub.ReConnectCount = 0 // 重置重连次数
|
||||
}
|
||||
|
||||
// 是否需要重连
|
||||
func (pub *Puller) Reconnect() (ok bool) {
|
||||
ok = pub.Config.RePull == -1 || pub.ReConnectCount <= pub.Config.RePull
|
||||
|
Reference in New Issue
Block a user