feat: add extra event system

This commit is contained in:
langhuihui
2023-12-05 19:12:03 +08:00
parent 9e2ca2a670
commit 48d6e277e4
4 changed files with 36 additions and 7 deletions

View File

@@ -34,10 +34,14 @@ func (pub *Pusher) startPush(pusher IPusher) {
Pushers.Store(pub.RemoteURL, pusher)
defer Pushers.Delete(pub.RemoteURL)
defer pusher.Disconnect()
var startTime time.Time
for pusher.Info("start push"); pusher.Reconnect(); pusher.Warn("restart push") {
if time.Since(startTime) < 5*time.Second {
time.Sleep(5 * time.Second)
}
startTime = time.Now()
if err = pusher.Subscribe(pub.StreamPath, pusher); err != nil {
pusher.Error("push subscribe", zap.Error(err))
time.Sleep(time.Second * 5)
} else {
stream := pusher.GetSubscriber().Stream
if err = pusher.Connect(); err != nil {