Skip to content

Commit

Permalink
simple indication of online/offline status
Browse files Browse the repository at this point in the history
  • Loading branch information
pwielgolaski committed Oct 2, 2014
1 parent c099fdc commit 07de49b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion admin/data/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ <h1>Viewing All Routes</h1>
</tr>
</thead>
<tbody>
<tr ng-repeat="r in routes">
<tr ng-repeat="r in routes" ng-class="{ 'danger' : !r.Online }">
<td>{{r.Key}}</td>
<td>{{r.Patt}}</td>
<td>{{r.Addr}}</td>
Expand Down
3 changes: 3 additions & 0 deletions routing/routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Route struct {
Addr string // tcp dest
spoolDir string // where to store spool files (if enabled)
Spool bool // spool metrics to disk while endpoint down?
Online bool // state of connection online/offline
instrument *statsd.Client // to submit stats to

// set automatically in init, passed on in copy
Expand Down Expand Up @@ -60,6 +61,7 @@ func (route *Route) Copy() *Route {
Spool: route.Spool,
instrument: route.instrument,
Reg: route.Reg,
Online: route.Online,
}
}

Expand Down Expand Up @@ -183,6 +185,7 @@ func (route *Route) relay() {
}
case new_conn := <-route.connUpdates:
conn = new_conn // can be nil and that's ok (it means we had to [re]connect but couldn't)
route.Online = conn != nil
case <-ticker.C: // periodically try to bring connection (back) up, if we have to, and no other connect is happening
if conn == nil && conn_updates == 0 {
go route.updateConn(route.Addr)
Expand Down

0 comments on commit 07de49b

Please sign in to comment.