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
|
scripts/*.go
|
||||||
docker/**/data
|
docker/**/data
|
||||||
TODO*
|
TODO*
|
||||||
|
.idea
|
||||||
|
|
|
@ -82,6 +82,7 @@ func HandleEvents(
|
||||||
events, errc := events.Subscribe(ctx)
|
events, errc := events.Subscribe(ctx)
|
||||||
logger.Debugln("events: stream opened")
|
logger.Debugln("events: stream opened")
|
||||||
|
|
||||||
|
timeoutChan := time.After(24 * time.Hour)
|
||||||
L:
|
L:
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
@ -91,7 +92,7 @@ func HandleEvents(
|
||||||
case <-errc:
|
case <-errc:
|
||||||
logger.Debugln("events: stream error")
|
logger.Debugln("events: stream error")
|
||||||
break L
|
break L
|
||||||
case <-time.After(time.Hour):
|
case <-timeoutChan:
|
||||||
logger.Debugln("events: stream timeout")
|
logger.Debugln("events: stream timeout")
|
||||||
break L
|
break L
|
||||||
case <-time.After(pingInterval):
|
case <-time.After(pingInterval):
|
||||||
|
|
|
@ -63,6 +63,7 @@ func HandleGlobal(
|
||||||
events, errc := events.Subscribe(ctx)
|
events, errc := events.Subscribe(ctx)
|
||||||
logger.Debugln("events: stream opened")
|
logger.Debugln("events: stream opened")
|
||||||
|
|
||||||
|
timeoutChan := time.After(24 * time.Hour)
|
||||||
L:
|
L:
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
@ -72,7 +73,7 @@ func HandleGlobal(
|
||||||
case <-errc:
|
case <-errc:
|
||||||
logger.Debugln("events: stream error")
|
logger.Debugln("events: stream error")
|
||||||
break L
|
break L
|
||||||
case <-time.After(time.Hour):
|
case <-timeoutChan:
|
||||||
logger.Debugln("events: stream timeout")
|
logger.Debugln("events: stream timeout")
|
||||||
break L
|
break L
|
||||||
case <-time.After(pingInterval):
|
case <-time.After(pingInterval):
|
||||||
|
|
|
@ -102,6 +102,7 @@ func HandleLogStream(
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
timeoutChan := time.After(24 * time.Hour)
|
||||||
L:
|
L:
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
@ -109,7 +110,7 @@ func HandleLogStream(
|
||||||
break L
|
break L
|
||||||
case <-errc:
|
case <-errc:
|
||||||
break L
|
break L
|
||||||
case <-time.After(time.Hour):
|
case <-timeoutChan:
|
||||||
break L
|
break L
|
||||||
case <-time.After(pingInterval):
|
case <-time.After(pingInterval):
|
||||||
io.WriteString(w, ": ping\n\n")
|
io.WriteString(w, ": ping\n\n")
|
||||||
|
|
Loading…
Reference in a new issue