Browse Source

update 切片复制,避免引用问题

dev
lucas 1 month ago
parent
commit
391da8803e
  1. 8
      et_sink/sinkHandler.go

8
et_sink/sinkHandler.go

@ -126,7 +126,9 @@ func (the *SinkHandler) dumpRawBatchMonitor() {
if len(the.dataQueueRaw) > 0 {
count := len(the.dataQueueRaw)
log.Printf("es写入dataQueueRaw数据 count====> %d", count)
needDump := the.dataQueueRaw[:count] //make([]common_models.EsRaw, count)
needDump := make([]common_models.EsRaw, count)
//避免引用问题
copy(needDump, the.dataQueueRaw[:count])
the.dataQueueRaw = the.dataQueueRaw[count:]
go the.dumpRaws(needDump)
}
@ -164,7 +166,9 @@ func (the *SinkHandler) dumpThemeBatchMonitor() {
}
if len(the.dataQueueTheme) > 0 {
count := len(the.dataQueueTheme)
needDump := the.dataQueueTheme[:count]
needDump := make([]common_models.EsTheme, count)
//避免引用问题
copy(needDump, the.dataQueueTheme[:count])
the.dataQueueTheme = the.dataQueueTheme[count:]
go the.dumpThemes(needDump)
}

Loading…
Cancel
Save