github.com/alibaba/ilogtail/pkg@v0.0.0-20250526110833-c53b480d046c/protocol/sls_logs_pool.go (about) 1 package protocol 2 3 // import "sync" 4 5 // var slsLogPool sync.Pool 6 // var slsLogGroupPool sync.Pool 7 8 // // var slsLogContentPool sync.Pool 9 10 // // // GetSLSLogContent return a LogContent 11 // // func GetSLSLogContent() *Log_Content { 12 // // return slsLogContentPool.Get().(*Log_Content) 13 // // } 14 15 // // // CacheSLSLogContent( cache a LogContent 16 // // func CacheSLSLogContent(content *Log_Content) { 17 // // content.Key = "" 18 // // content.Value = "" 19 // // slsLogContentPool.Put(content) 20 // // } 21 22 // // GetSLSLog return a Log 23 // func GetSLSLog() *Log { 24 // return &Log{} 25 // return slsLogPool.Get().(*Log) 26 // } 27 28 // // CacheSLSLog cache a Log 29 // func CacheSLSLog(log *Log) { 30 // return 31 // // for _, logContents := range log.Contents { 32 // // CacheSLSLogContent(logContents) 33 // // } 34 // // reset log contents 35 // log.Contents = nil 36 // slsLogPool.Put(log) 37 // } 38 39 // // CopySLSLog deep copy for Log 40 // func CopySLSLog(log *Log) *Log { 41 // newLog := GetSLSLog() 42 // newLog.Time = log.Time 43 // // @todo, need to deep copy Contents 44 // newLog.Contents = log.Contents 45 // return newLog 46 // } 47 48 // // GetSLSLogGroup return a LogGroup 49 // func GetSLSLogGroup() *LogGroup { 50 // return &LogGroup{} 51 // return slsLogGroupPool.Get().(*LogGroup) 52 // } 53 54 // // CacheSLSLogGroup cache a LogGroup 55 // func CacheSLSLogGroup(logGroup *LogGroup) { 56 // return 57 // for _, log := range logGroup.Logs { 58 // CacheSLSLog(log) 59 // } 60 // // reset logs and tags 61 // logGroup.LogTags = nil 62 // logGroup.Logs = nil 63 // slsLogGroupPool.Put(logGroup) 64 // } 65 66 // // CopySLSLogGroup deep copy for LogGroup 67 // func CopySLSLogGroup(logGroup *LogGroup) *LogGroup { 68 // newLogGroup := GetSLSLogGroup() 69 // newLogGroup.Topic = logGroup.Topic 70 // // @todo, need to deep copy Tags 71 // newLogGroup.LogTags = logGroup.LogTags 72 // for _, log := range logGroup.Logs { 73 // newLogGroup.Logs = append(newLogGroup.Logs, CopySLSLog(log)) 74 // } 75 // return newLogGroup 76 // } 77 78 // func init() { 79 // slsLogPool.New = func() interface{} { 80 // return &Log{} 81 // } 82 // slsLogGroupPool.New = func() interface{} { 83 // return &LogGroup{} 84 // } 85 // // slsLogContentPool.New = func() interface{} { 86 // // return &Log_Content{} 87 // // } 88 // }