You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
914 B
36 lines
914 B
package data_source
|
|
|
|
import (
|
|
"log"
|
|
"time"
|
|
)
|
|
|
|
type AggDataHandler struct {
|
|
key string
|
|
topic string
|
|
partitionID int
|
|
dataChannel chan *RPCPayload // 用于发送打包后的数据
|
|
}
|
|
|
|
func NewAggDataHandler(key, topic string, partitionID int) *AggDataHandler {
|
|
handler := &AggDataHandler{
|
|
key: key,
|
|
topic: topic,
|
|
partitionID: partitionID,
|
|
dataChannel: make(chan *RPCPayload, 10),
|
|
}
|
|
|
|
return handler
|
|
}
|
|
|
|
func (h *AggDataHandler) HandleMessage(structId string, values []string) bool {
|
|
h.dataChannel <- &RPCPayload{Id: structId, Messages: values}
|
|
log.Printf("****** AggDataHandler.HandleMessage() ,h.dataChannel【%p】通道数据量:%d/%d", h.dataChannel, len(h.dataChannel), cap(h.dataChannel))
|
|
time.Sleep(50 * time.Millisecond)
|
|
return true
|
|
}
|
|
|
|
// GetDataChannel 返回 dataChannel
|
|
func (h *AggDataHandler) GetDataChannel() chan *RPCPayload {
|
|
return h.dataChannel
|
|
}
|
|
|