Skip to content

Commit

Permalink
fix(logspout): perform a no-op if etcd route is identical
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Fisher committed Apr 5, 2016
1 parent 0be5061 commit 1dd208f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion logspout/logspout.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,19 @@ func main() {
for {
// NOTE(bacongobbler): sleep for a bit before doing the discovery loop again
time.Sleep(10 * time.Second)
newRoute := getEtcdRoute(etcd)
oldRoute, err := router.Get("etcd")
// router.Get only returns an error if the route doesn't exist. If it does,
// then we can skip this check and just add the new route to the routing table
if err == nil &&
newRoute.Target.Protocol == oldRoute.Target.Protocol &&
newRoute.Target.Addr == oldRoute.Target.Addr {
// NOTE(bacongobbler): the two targets are the same; perform a no-op
continue
}
// NOTE(bacongobbler): this operation is a no-op if the route doesn't exist
router.Remove("etcd")
router.Add(getEtcdRoute(etcd))
router.Add(newRoute)
}
}()
}
Expand Down

0 comments on commit 1dd208f

Please sign in to comment.