refactor runner using titan

This commit is contained in:
Pedro Nasser
2016-07-24 17:46:08 -03:00
parent a8e984f834
commit 14cc57fd9c
12 changed files with 339 additions and 369 deletions

15
api/models/config.go Normal file
View File

@@ -0,0 +1,15 @@
package models
type Config struct {
DatabaseURL string `json:"db"`
API string `json:"api"`
Logging struct {
To string `json:"to"`
Level string `json:"level"`
Prefix string `json:"prefix"`
}
}
func (c *Config) Validate() error {
return nil
}

View File

@@ -17,5 +17,6 @@ func ApplyAppFilter(app *App, filter *AppFilter) bool {
}
func ApplyRouteFilter(route *Route, filter *RouteFilter) bool {
return true
return (filter.Path != "" && route.Path == filter.Path) &&
(filter.AppName != "" && route.AppName == filter.AppName)
}

View File

@@ -54,5 +54,6 @@ func (r *Route) Validate() error {
}
type RouteFilter struct {
Path string
AppName string
}

13
api/models/runner.go Normal file
View File

@@ -0,0 +1,13 @@
package models
import "errors"
var (
ErrRunnerRouteNotFound = errors.New("Route not found on that application")
ErrRunnerInvalidPayload = errors.New("Invalid payload")
ErrRunnerRunRoute = errors.New("Couldn't run this route in the job server")
ErrRunnerAPICantConnect = errors.New("Couldn`t connect to the job server API")
ErrRunnerAPICreateJob = errors.New("Could not create a job in job server")
ErrRunnerInvalidResponse = errors.New("Invalid response")
ErrRunnerTimeout = errors.New("Timed out")
)