Skip to content

Commit

Permalink
re #149 use Ticker for event stream connection restoration
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergei Egorov authored and bsideup committed Sep 14, 2015
1 parent 9ef0fd3 commit ddfe126
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion main/bamboo/bamboo.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,9 @@ func listenToEventStream(conf configuration.Configuration, eventBus *event_bus.E
client.Timeout = 0 * time.Second

for _, marathon := range conf.Marathon.Endpoints() {
ticker := time.NewTicker(1 * time.Second)
go func() {
for {
for _ = range ticker.C {
req, err := http.NewRequest("GET", marathon+"/v2/events", nil)
req.Header.Set("Accept", "text/event-stream")
if err != nil {
Expand All @@ -200,6 +201,8 @@ func listenToEventStream(conf configuration.Configuration, eventBus *event_bus.E

resp, err := client.Do(req)
if err != nil {
errorMsg := "An error occurred while making a request to Marathon events system: %s\n"
log.Printf(errorMsg, err)
continue
}

Expand Down

0 comments on commit ddfe126

Please sign in to comment.