update go-marathon to 441a03a
in order to get the latest fixes regarding SSE subscription failover.
This commit is contained in:
parent
885b9f371c
commit
2ddae2e856
7 changed files with 162 additions and 43 deletions
22
vendor/github.com/donovanhide/eventsource/server.go
generated
vendored
22
vendor/github.com/donovanhide/eventsource/server.go
generated
vendored
|
@ -4,6 +4,7 @@ import (
|
|||
"log"
|
||||
"net/http"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type subscription struct {
|
||||
|
@ -32,6 +33,8 @@ type Server struct {
|
|||
subs chan *subscription
|
||||
unregister chan *subscription
|
||||
quit chan bool
|
||||
isClosed bool
|
||||
isClosedMutex sync.RWMutex
|
||||
}
|
||||
|
||||
// Create a new Server ready for handler creation and publishing events
|
||||
|
@ -51,6 +54,7 @@ func NewServer() *Server {
|
|||
// Stop handling publishing
|
||||
func (srv *Server) Close() {
|
||||
srv.quit <- true
|
||||
srv.markServerClosed()
|
||||
}
|
||||
|
||||
// Create a new handler for serving a specified channel
|
||||
|
@ -69,6 +73,12 @@ func (srv *Server) Handler(channel string) http.HandlerFunc {
|
|||
}
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
// If the Handler is still active even though the server is closed, stop here.
|
||||
// Otherwise the Handler will block while publishing to srv.subs indefinitely.
|
||||
if srv.isServerClosed() {
|
||||
return
|
||||
}
|
||||
|
||||
sub := &subscription{
|
||||
channel: channel,
|
||||
lastEventId: req.Header.Get("Last-Event-ID"),
|
||||
|
@ -165,3 +175,15 @@ func (srv *Server) run() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (srv *Server) isServerClosed() bool {
|
||||
srv.isClosedMutex.RLock()
|
||||
defer srv.isClosedMutex.RUnlock()
|
||||
return srv.isClosed
|
||||
}
|
||||
|
||||
func (srv *Server) markServerClosed() {
|
||||
srv.isClosedMutex.Lock()
|
||||
defer srv.isClosedMutex.Unlock()
|
||||
srv.isClosed = true
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue