func (p LeaveProcessor) Process() { app := types.GetApp(p.AppId, p.GetAgent()) app.Lock() if app.Exists() { keys := []types.AppKey{} for _, e := range app.GetExports() { keys = append(keys, e.GetAppKey()) } conn, _ := app.GetConnection() conn.Close() printDebug("LEAVE locking") printDebug("LEAVE unlocking") if !app.IsNode() { for _, exp := range app.GetExports() { printDebug("LEAVE unlocking") var m messages.RemoveExportMessage m.ExportId = exp.GetId() var smp SendMessageProcessor smp.Msg = m smp.GenericProcessor = processor.GetGenericProcessor() for _, n := range types.GetNodes(p.GetAgent()) { smp.App = n p.SpawnProcess(smp) } } for _, imp := range app.GetImports() { var m messages.RemoveImportMessage m.ImportId = imp.GetId() var smp SendMessageProcessor smp.Msg = m smp.GenericProcessor = processor.GetGenericProcessor() for _, n := range types.GetNodes(p.GetAgent()) { smp.App = n p.SpawnProcess(smp) } } printDebug("LEAVE removing") app.Remove() printDebug("LEAVE removed") for _, k := range keys { if k.Exists() { var esp ExportedStateProcessor esp.AppKey = k esp.GenericProcessor = processor.GetGenericProcessor() p.SpawnProcess(esp) } } } } }
func (p UpdateExportProcessor) Process() { printDebug("UPDATEEXPORT", p.UpdateExportMsg) Export := types.GetExportById(p.UpdateExportMsg.ExportId, p.GetAgent()) Export.UpdateTags(p.UpdateExportMsg.Tags) var pjp PendingJobProcessor pjp.Appkey = Export.GetAppKey() pjp.GenericProcessor = processor.GetGenericProcessor() p.SpawnProcess(pjp) var uesp ExportedStateProcessor uesp.AppKey = Export.GetAppKey() uesp.GenericProcessor = processor.GetGenericProcessor() p.SpawnProcess(uesp) if !Export.GetApp().IsNode() { for _, node := range types.GetNodes(p.GetAgent()) { node.Lock() var smp SendMessageProcessor smp.App = node smp.Msg = p.UpdateExportMsg smp.GenericProcessor = processor.GetGenericProcessor() p.SpawnProcess(smp) node.Unlock() } } }
func (p StopListenProcessor) Process() { Import := types.GetImportById(p.StopListenMsg.ImportId, p.GetAgent()) Import.StopListenToFunction(p.StopListenMsg.FunctionName) if !Import.GetApp().IsNode() { for _, n := range types.GetNodes(p.GetAgent()) { var smp SendMessageProcessor smp.App = n smp.Msg = p.StopListenMsg smp.GenericProcessor = processor.GetGenericProcessor() p.SpawnProcess(smp) } } }
func (p AddExportProcessor) Process() { app := types.GetApp(p.AppId, p.GetAgent()) if !app.Exists() { mprint("Could not add exmport, app does not exist") return } app.Lock() Export := types.GetExport(p.AppId, p.AddExportMsg.AppKey, p.AddExportMsg.Tags, p.AddExportMsg.ExportId, p.GetAgent()) Export.Add() if !app.IsNode() { var smp SendMessageProcessor smp.App = app smp.Msg = messages.ExportAddedMessage{Export.GetId(), p.AddExportMsg.AppKey, p.AddExportMsg.Tags} smp.GenericProcessor = processor.GetGenericProcessor() p.SpawnProcess(smp) } var pjp PendingJobProcessor pjp.Appkey = Export.GetAppKey() pjp.GenericProcessor = processor.GetGenericProcessor() p.SpawnProcess(pjp) var uesp ExportedStateProcessor uesp.AppKey = Export.GetAppKey() uesp.GenericProcessor = processor.GetGenericProcessor() p.SpawnProcess(uesp) if !app.IsNode() { p.AddExportMsg.ExportId = Export.GetId() for _, node := range types.GetNodes(p.GetAgent()) { var smp SendMessageProcessor smp.App = node smp.Msg = p.AddExportMsg smp.GenericProcessor = processor.GetGenericProcessor() p.SpawnProcess(smp) } } app.Unlock() }
func (p UpdateImportProcessor) Process() { Import := types.GetImportById(p.UpdateImportMsg.ImportId, p.GetAgent()) Import.UpdateTags(p.UpdateImportMsg.Tags) if !Import.GetApp().IsNode() { var smp SendMessageProcessor smp.App = Import.GetApp() smp.Msg = messages.ImportUpdatedMessage{Import.GetId(), Import.HasExporter()} smp.GenericProcessor = processor.GetGenericProcessor() p.SpawnProcess(smp) for _, node := range types.GetNodes(p.GetAgent()) { node.Lock() var smp SendMessageProcessor smp.App = node smp.Msg = p.UpdateImportMsg smp.GenericProcessor = processor.GetGenericProcessor() p.SpawnProcess(smp) node.Unlock() } } }