feat: migrate from msgpack to protobuf (handler-base v1.0.0)
- Replace msgpack encoding with protobuf wire format - Update field names to proto convention (SessionId) - Cast int fields to int32 (ChunkIndex, TotalChunks, SampleRate, Count) - Use pointer slices for repeated messages ([]*TTSVoiceInfo) - Rewrite tests for proto round-trips
This commit is contained in:
24
e2e_test.go
24
e2e_test.go
@@ -12,7 +12,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"git.daviestechlabs.io/daviestechlabs/handler-base/messages"
|
||||
"github.com/vmihailenco/msgpack/v5"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
// ────────────────────────────────────────────────────────────────────────────
|
||||
@@ -67,21 +67,21 @@ func TestSynthesisE2E_StreamChunks(t *testing.T) {
|
||||
|
||||
// Verify typed chunk struct
|
||||
msg := messages.TTSAudioChunk{
|
||||
SessionID: "test-session",
|
||||
ChunkIndex: chunkIdx,
|
||||
TotalChunks: totalChunks,
|
||||
SessionId: "test-session",
|
||||
ChunkIndex: int32(chunkIdx),
|
||||
TotalChunks: int32(totalChunks),
|
||||
Audio: chunk,
|
||||
IsLast: isLast,
|
||||
SampleRate: 24000,
|
||||
}
|
||||
|
||||
// Round-trip through msgpack
|
||||
data, _ := msgpack.Marshal(&msg)
|
||||
data, _ := proto.Marshal(&msg)
|
||||
var decoded messages.TTSAudioChunk
|
||||
_ = msgpack.Unmarshal(data, &decoded)
|
||||
_ = proto.Unmarshal(data, &decoded)
|
||||
|
||||
if decoded.SessionID != "test-session" {
|
||||
t.Errorf("chunk %d: session = %v", chunkIdx, decoded.SessionID)
|
||||
if decoded.SessionId != "test-session" {
|
||||
t.Errorf("chunk %d: session = %v", chunkIdx, decoded.SessionId)
|
||||
}
|
||||
if decoded.IsLast != isLast {
|
||||
t.Errorf("chunk %d: is_last = %v, want %v", chunkIdx, decoded.IsLast, isLast)
|
||||
@@ -266,13 +266,13 @@ func BenchmarkAudioChunking(b *testing.B) {
|
||||
}
|
||||
chunk := audioBytes[i:end]
|
||||
msg := &messages.TTSAudioChunk{
|
||||
SessionID: "bench",
|
||||
ChunkIndex: i / chunkSize,
|
||||
TotalChunks: totalChunks,
|
||||
SessionId: "bench",
|
||||
ChunkIndex: int32(i / chunkSize),
|
||||
TotalChunks: int32(totalChunks),
|
||||
Audio: chunk,
|
||||
SampleRate: 24000,
|
||||
}
|
||||
_, _ = msgpack.Marshal(msg)
|
||||
_, _ = proto.Marshal(msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user