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:
parent
352eff9062
commit
5426fb7b31
4 changed files with 7 additions and 3 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -10,3 +10,4 @@ release/
|
|||
scripts/*.go
|
||||
docker/**/data
|
||||
TODO*
|
||||
.idea
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue