event-stream supports timeout (#3125)

* event-stream supports timeout
* Increaded timeout to 24 hours for events/build.go
* Increased timeout to 24 hours for events/global.go
* Increased timeout to 24 hours for events/logs.go
This commit is contained in:
zc 2021-08-31 23:45:07 +08:00 committed by GitHub
parent 352eff9062
commit 5426fb7b31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 3 deletions

1
.gitignore vendored
View file

@ -10,3 +10,4 @@ release/
scripts/*.go
docker/**/data
TODO*
.idea

View file

@ -82,6 +82,7 @@ func HandleEvents(
events, errc := events.Subscribe(ctx)
logger.Debugln("events: stream opened")
timeoutChan := time.After(24 * time.Hour)
L:
for {
select {
@ -91,7 +92,7 @@ func HandleEvents(
case <-errc:
logger.Debugln("events: stream error")
break L
case <-time.After(time.Hour):
case <-timeoutChan:
logger.Debugln("events: stream timeout")
break L
case <-time.After(pingInterval):

View file

@ -63,6 +63,7 @@ func HandleGlobal(
events, errc := events.Subscribe(ctx)
logger.Debugln("events: stream opened")
timeoutChan := time.After(24 * time.Hour)
L:
for {
select {
@ -72,7 +73,7 @@ func HandleGlobal(
case <-errc:
logger.Debugln("events: stream error")
break L
case <-time.After(time.Hour):
case <-timeoutChan:
logger.Debugln("events: stream timeout")
break L
case <-time.After(pingInterval):

View file

@ -102,6 +102,7 @@ func HandleLogStream(
return
}
timeoutChan := time.After(24 * time.Hour)
L:
for {
select {
@ -109,7 +110,7 @@ func HandleLogStream(
break L
case <-errc:
break L
case <-time.After(time.Hour):
case <-timeoutChan:
break L
case <-time.After(pingInterval):
io.WriteString(w, ": ping\n\n")