This commit is contained in:
2026-06-15 01:20:30 +03:00
parent b32279deaf
commit 80309aab99
20 changed files with 149 additions and 40 deletions

View File

@@ -1,7 +1,6 @@
package transform
import (
"fmt"
"io"
bin "gordenko.dev/dima/bin/little"
@@ -102,7 +101,7 @@ type CumulativeMeasureWriter struct {
}
func NewCumulativeMeasureWriter(dst io.Writer, since uint32) *CumulativeMeasureWriter {
fmt.Println("NewCumulativeMeasureWriter")
//fmt.Println("NewCumulativeMeasureWriter")
// 20 - это timestamp, value, total
return &CumulativeMeasureWriter{
arr: make([]byte, 20),
@@ -128,13 +127,13 @@ func (s *CumulativeMeasureWriter) feed(timestamp uint32, value float64, isBuffer
s.responder.AppendRecord(s.arr)
}
}
fmt.Println("feed:", timestamp, value, isBuffer)
//fmt.Println("feed:", timestamp, value, isBuffer)
s.endTimestamp = timestamp
s.endValue = value
}
func (s *CumulativeMeasureWriter) pack(total float64) {
fmt.Println("PACK")
//fmt.Println("PACK")
bin.PutUint32(s.arr[0:], s.endTimestamp)
bin.PutFloat64(s.arr[4:], s.endValue)
bin.PutFloat64(s.arr[12:], total)

View File

@@ -38,13 +38,13 @@ func NewChunkedResponder(dst io.Writer) *ChunkedResponder {
func (s *ChunkedResponder) BufferRecord(rec []byte) {
s.buf.Write(rec)
s.recordsQty++
fmt.Println("BufferRecord", s.recordsQty)
//fmt.Println("BufferRecord", s.recordsQty)
}
func (s *ChunkedResponder) AppendRecord(rec []byte) error {
s.buf.Write(rec)
s.recordsQty++
fmt.Println("AppendRecord", s.recordsQty)
//fmt.Println("AppendRecord", s.recordsQty)
if s.buf.Len() < 1500 {
return nil
@@ -63,7 +63,7 @@ func (s *ChunkedResponder) AppendRecord(rec []byte) error {
}
func (s *ChunkedResponder) Flush() error {
fmt.Println("Flush", s.recordsQty)
//fmt.Println("Flush", s.recordsQty)
if s.recordsQty > 0 {
if err := s.sendBuffered(); err != nil {
return err
@@ -78,14 +78,14 @@ func (s *ChunkedResponder) Flush() error {
}
func (s *ChunkedResponder) sendBuffered() (err error) {
fmt.Println("sendBuffered", s.recordsQty)
//fmt.Println("sendBuffered", s.recordsQty)
msg := s.buf.Bytes()
bin.PutUint32(msg[1:], uint32(s.recordsQty))
fmt.Printf("put uint16: %d\n", msg[:3])
//fmt.Printf("put uint16: %d\n", msg[:3])
fmt.Printf("send %d records\n", s.recordsQty)
//fmt.Printf("send %d records\n", s.recordsQty)
fmt.Printf("send buffered: %d, qty: %d\n", msg, s.recordsQty)
//fmt.Printf("send buffered: %d, qty: %d\n", msg, s.recordsQty)
n, err := s.dst.Write(msg)
if err != nil {