Commit 865d668c authored by Lukas Burgey's avatar Lukas Burgey
Browse files

Fix error handling on fetch

parent 8779366e
......@@ -100,15 +100,11 @@ func (c *config) taskServices(t task) (services []service, err error) {
}
}
// try the group based services
// TODO is this desired?
if len(services) == 0 {
for _, groupServices := range c.GroupToServices {
for _, groupService := range groupServices {
if groupService.Name == t.RoutingKey {
services = []service{groupService}
return
}
for _, groupServices := range c.GroupToServices {
for _, groupService := range groupServices {
if groupService.Name == t.RoutingKey {
services = []service{groupService}
return
}
}
}
......@@ -118,9 +114,9 @@ func (c *config) taskServices(t task) (services []service, err error) {
services, ok = c.GroupToServices[t.RoutingKey]
if !ok {
err = fmt.Errorf(
"Group %s has no mapped services! Unable to get service for task %s",
t.RoutingKey,
"%s: Group %s has no mapped services",
t,
t.RoutingKey,
)
return
}
......@@ -140,18 +136,16 @@ func (c *config) taskFetcher() {
// start ticker
ticker := time.NewTicker(c.FetchInterval)
go func() {
for {
go func() {
if err := c.fetchTasks(); err != nil {
log.Printf("[Fetch] error fetching: %s", err)
}
}()
for {
go func() {
if err := c.fetchTasks(); err != nil {
log.Printf("[Fetch] error fetching: %s", err)
}
}()
// wait for a tick
<-ticker.C
}
}()
// wait for a tick
<-ticker.C
}
}
// handles tasks in c.NewTasks
......@@ -253,7 +247,10 @@ func (c *config) fetchTasks() (err error) {
for _, task := range newTasks {
err = c.scheduleTask(task)
if err != nil {
return
log.Printf("[Fetch] %v", err)
// we execute all tasks even when one fails
err = nil
}
}
return
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment