github.com/zartbot/goflow@v0.0.0-20221001080520-456f7dfad288/service/output/record_map.go (about) 1 package output 2 3 import ( 4 "time" 5 6 "github.com/zartbot/goflow/datarecord" 7 "github.com/zartbot/goflow/service/ciscoavc" 8 "github.com/zartbot/goflow/service/flowinfo" 9 "github.com/zartbot/goflow/service/geoipmap" 10 "github.com/zartbot/goflow/service/optiontemplatemap" 11 ) 12 13 func RecordMap(d *datarecord.DataFrame) { 14 d.TypeAssertion() 15 16 createAt := time.Unix(int64(d.ExportTime), 0) 17 for _, value := range d.Record { 18 value["CreateAt"] = createAt 19 value["AgentID"] = d.AgentID 20 value["Type"] = d.Type 21 optiontemplatemap.UpdateInterfaceMap(value, d.AgentID) 22 optiontemplatemap.UpdateAppMap(value, d.AgentID) 23 optiontemplatemap.UpdateCiscoVarString(value, d.AgentID) 24 flowinfo.UpdateFlowInfo(value, true) 25 ciscoavc.ExtendField(value) 26 27 } 28 } 29 30 //RecordStreamProccesor : stream process worker.... 31 func RecordStreamProccesor(dfchan chan *datarecord.DataFrame, fanoutList []chan *datarecord.DataFrame) { 32 for { 33 d := <-dfchan 34 RecordMap(d) 35 if (d.Type != "NULL") && (d.Type != "OptionTemplate") { 36 for _, item := range fanoutList { 37 item <- d 38 } 39 } 40 } 41 } 42 43 func RecordMapWithPrediction(d *datarecord.DataFrame, g *geoipmap.GeoIPCollector) { 44 d.TypeAssertion() 45 46 createAt := time.Unix(int64(d.ExportTime), 0) 47 for _, value := range d.Record { 48 value["CreateAt"] = createAt 49 value["AgentID"] = d.AgentID 50 value["Type"] = d.Type 51 optiontemplatemap.UpdateInterfaceMap(value, d.AgentID) 52 optiontemplatemap.UpdateAppMap(value, d.AgentID) 53 optiontemplatemap.UpdateCiscoVarString(value, d.AgentID) 54 optiontemplatemap.UpdateC3PLMap(value, d.AgentID) 55 flowinfo.UpdateFlowInfo(value, true) 56 geoipmap.UpdateGeoLocationInfo(value, g) 57 ciscoavc.ExtendField(value) 58 } 59 }