示例#1
0
func sendDependencyNotice(a *app.App) {
	// notify everyone who depends on us
	for _, cpb := range a.Manifest.Capabilities {
		for _, dependent := range registry.GetDependents(cpb) {
			body := make(jsonData)
			inner := make(jsonData)
			inner[a.Manifest.InstanceId] = a.StatusString()
			body[cpb.Name] = inner
			dependent.Send("APP_DEPENDENCY", body)
		}
	}
}
示例#2
0
func sendManifestOkAndDependencies(a *app.App) {
	// send manifest ok
	body := make(map[string]interface{})
	body["instanceId"] = a.Manifest.InstanceId
	a.Send("APP_MANIFEST_OK", body)
	// send dependencies
	body = make(map[string]interface{})
	for _, dep := range a.Manifest.Dependencies {
		inner := make(map[string]string)
		body[dep.Name] = inner
		for _, provider := range registry.GetProviders(dep) {
			inner[provider.Manifest.InstanceId] = provider.StatusString()
		}
	}
	a.Send("APP_DEPENDENCY", body)
}
示例#3
0
func getMockApp() *app.App {
	// construct a new app
	a := new(app.App)
	a.Manifest = new(app.Manifest)
	a.Manifest.Name = "name1"
	a.Manifest.InstanceId = "instance1"

	// construct capabilities
	caps := make([]*app.Capability, 2)
	cap1 := new(app.Capability)
	v1, _ := semver.NewVersion("1.1.1")
	v2, _ := semver.NewVersion("1.1.2")
	cap1.Version = *v1
	cap1.Name = "capability1"
	caps[0] = cap1
	cap2 := new(app.Capability)
	cap2.Version = *v2
	cap2.Name = "capability2"
	caps[1] = cap2
	a.Manifest.Capabilities = caps

	// construct dependencies
	deps := make([]*app.Capability, 2)
	dep1 := new(app.Capability)
	dep1.Version = *v1
	dep1.Name = "dependency1"
	deps[0] = dep1
	dep2 := new(app.Capability)
	dep2.Version = *v2
	dep2.Name = "dependency2"
	deps[1] = dep2

	a.Manifest.Dependencies = deps

	return a
}
示例#4
0
func sendManifestFail(a *app.App, reason string) {
	body := make(map[string]interface{})
	body["message"] = reason
	a.Send("APP_MANIFEST_FAIL", body)
}
示例#5
0
// Changes the status of App a to the given status and priority.
// By design priority is ignored for all statuses other than STATUS_IN_USE.
func ChangeAppStatus(a *app.App, stat int, prio int) {
	a.Status = stat
	a.Priority = prio
	sendDependencyNotice(a)
}