Add app source, add vendoring and module support

This commit is contained in:
Mayuresh Gaitonde
2019-10-16 15:57:55 -07:00
parent b49447a374
commit a8fd79c0e1
991 changed files with 505284 additions and 415 deletions

View File

@@ -53,6 +53,7 @@ type App struct {
Vip *net.IPNet
Monitors Monitors
Nats []string
Source string
}
func (a *App) Equal(other *App) bool {
@@ -67,11 +68,11 @@ func (a *App) Equal(other *App) bool {
return a.Name == other.Name && a.Vip.String() == other.Vip.String()
}
func NewApp(appName, vip string, monitors []string, nats []string) (*App, error) {
func NewApp(appName, vip string, monitors []string, nats []string, source string) (*App, error) {
if appName == "" {
return nil, fmt.Errorf("Invalid app name")
}
app := &App{Name: appName, Nats: nats}
app := &App{Name: appName, Nats: nats, Source: source}
_, ipnet, err := net.ParseCIDR(vip)
if err != nil {
return nil, fmt.Errorf("Invalid VIP specified, need ip/mask")

View File

@@ -86,7 +86,7 @@ func (c *ConsulMon) queryServices() ([]*App, error) {
glog.Errorf("No vip Tag found in matched service :%s", service.Service)
continue
}
app, err := NewApp(service.Service, vip, monitors, nats)
app, err := NewApp(service.Service, vip, monitors, nats, "consul")
if err != nil {
glog.Errorf("Unable to add consul app: %v", err)
continue

View File

@@ -97,7 +97,7 @@ func NewMonitor(config *c.Config) *MonitorMgr {
mon.config = config
// add apps defined in config
for _, a := range config.Apps {
app, err := NewApp(a.Name, a.Vip, a.Monitors, a.Nats)
app, err := NewApp(a.Name, a.Vip, a.Monitors, a.Nats, "config")
if err != nil {
glog.Errorf("Failed to add configured app %s: %v", a.Name, err)
continue
@@ -119,7 +119,10 @@ func (m *MonitorMgr) consulMon() {
// remove currently running apps that are not discovered in this pass
var toRemove []string
m.Lock()
for name := range m.monitors {
for name, mon := range m.monitors {
if mon.app.Source != "consul" {
continue
}
var found bool
for _, app := range apps {
if name == app.Name {