Esempio n. 1
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)
}
Esempio n. 2
0
// send this message query to all targeted apps
func (c *commandStrategy) msgQuery() error {
	c.app.RWMutex.RLock()
	defer c.app.RWMutex.RUnlock()

	logging.Debug("Processing query from %s", c.app.Manifest.InstanceId)
	mq, err := parseMsgQuery(c)
	if err != nil {
		return err
	}

	msg_archive.RecordMsg(c.app, mq.id)
	body := make(jsonData)
	body["fromInstanceId"] = c.app.Manifest.InstanceId
	body["id"] = mq.id
	body["priority"] = mq.priority
	body["data"] = mq.data
	body["instanceId"] = mq.instanceIds
	body["action"] = mq.action
	body["capability"] = mq.capability.Name

	// if this is an undirected query
	if len(mq.instanceIds) == 0 {
		// send to all providers of the capability
		for _, provider := range registry.GetProviders(mq.capability) {
			provider.Send("MSG_QUERY", body)
		}
	} else {
		// this is a directed query, send to all given instance ids
		for _, instName := range mq.instanceIds {
			if inst, ok := registry.GetInstance(instName); ok {
				inst.Send("MSG_QUERY", body)
			}
		}
	}
	return nil
}