github.com/mdaxf/iac@v0.0.0-20240519030858-58a061660378/engine/com/trancodecom.go (about) 1 package com 2 3 import ( 4 "encoding/json" 5 "fmt" 6 "time" 7 8 "github.com/mdaxf/iac/com" 9 "github.com/mdaxf/iac/engine/types" 10 "github.com/mdaxf/iac/logger" 11 ) 12 13 func SendTestResultMessageBus(trancode string, funcgroup string, function string, 14 type_ string, status string, 15 inputs map[string]interface{}, outputs map[string]interface{}, 16 systemsession map[string]interface{}, usersession map[string]interface{}, 17 err error, ClientID string, User string) { 18 19 go func() { 20 iLog := logger.Log{ModuleName: logger.TranCode, User: "System", ControllerName: "TransCode"} 21 22 startTime := time.Now() 23 defer func() { 24 elapsed := time.Since(startTime) 25 iLog.PerformanceWithDuration("engine.TranCode.SendTestResultMessageBus", elapsed) 26 }() 27 28 defer func() { 29 if err := recover(); err != nil { 30 iLog.Error(fmt.Sprintf("There is error to engine.TranCode.SendTestResultMessageBus with error: %s", err)) 31 // f.ErrorMessage = fmt.Sprintf("There is error to engine.funcs.ThrowErrorFuncs.Execute with error: %s", err) 32 33 } 34 }() 35 36 // Send message to IAC_TRANCODE_TEST_RESULT 37 38 // 1. Create message 39 Message := make(map[string]interface{}) 40 41 Message["ClientID"] = ClientID 42 Message["trancode"] = trancode 43 Message["funcgroup"] = funcgroup 44 Message["function"] = function 45 Message["type"] = type_ 46 Message["status"] = status 47 Message["inputs"] = inputs 48 Message["outputs"] = outputs 49 Message["systemsession"] = systemsession 50 Message["usersession"] = usersession 51 Message["err"] = err 52 53 jsonData, err := json.Marshal(Message) 54 if err != nil { 55 iLog.Error(fmt.Sprintf("Error:%v", err)) 56 return 57 } 58 59 jsonString := string(jsonData) 60 61 iLog.Debug(fmt.Sprintf("SendMessageFuncs Execute: topic, %s, message: %v", types.TranCodeTestResultMessageBus, jsonString)) 62 63 // 2. Send message 64 65 com.IACMessageBusClient.Invoke("send", types.TranCodeTestResultMessageBus, jsonString) 66 <-time.After(time.Microsecond * 100) 67 }() 68 }