feat: migrate from msgpack to protobuf (handler-base v1.0.0)
Some checks failed
CI / Lint (push) Failing after 2m49s
CI / Test (push) Successful in 3m36s
CI / Notify (push) Has been cancelled
CI / Docker Build & Push (push) Has been cancelled
CI / Release (push) Has been cancelled

- Replace msgpack encoding with protobuf wire format
- Update field names to proto convention (UserId, RequestId, EnableRag, etc.)
- Use messages.EffectiveQuery() standalone function
- Cast TopK to int32 for proto compatibility
- Rewrite tests for proto round-trips
This commit is contained in:
2026-02-21 15:30:04 -05:00
parent 87d0545d2c
commit e2176331c8
5 changed files with 62 additions and 63 deletions

View File

@@ -13,7 +13,7 @@ import (
"git.daviestechlabs.io/daviestechlabs/handler-base/clients"
"git.daviestechlabs.io/daviestechlabs/handler-base/messages"
"github.com/vmihailenco/msgpack/v5"
"google.golang.org/protobuf/proto"
)
// ────────────────────────────────────────────────────────────────────────────
@@ -167,33 +167,33 @@ func TestChatPipeline_LLMTimeout(t *testing.T) {
}
func TestChatPipeline_TypedDecoding(t *testing.T) {
// Verify typed struct decoding from msgpack (same path as OnTypedMessage).
raw := map[string]any{
"request_id": "req-e2e-001",
"user_id": "user-1",
"message": "hello",
"premium": true,
"enable_rag": false,
"enable_streaming": false,
"system_prompt": "Be brief.",
// Verify typed struct decoding from proto (same path as OnTypedMessage).
original := &messages.ChatRequest{
RequestId: "req-e2e-001",
UserId: "user-1",
Message: "hello",
Premium: true,
EnableRag: false,
EnableStreaming: false,
SystemPrompt: "Be brief.",
}
data, _ := msgpack.Marshal(raw)
data, _ := proto.Marshal(original)
var req messages.ChatRequest
if err := msgpack.Unmarshal(data, &req); err != nil {
if err := proto.Unmarshal(data, &req); err != nil {
t.Fatal(err)
}
if req.RequestID != "req-e2e-001" {
t.Errorf("RequestID = %q", req.RequestID)
if req.RequestId != "req-e2e-001" {
t.Errorf("RequestID = %q", req.RequestId)
}
if req.UserID != "user-1" {
t.Errorf("UserID = %q", req.UserID)
if req.UserId != "user-1" {
t.Errorf("UserID = %q", req.UserId)
}
if req.EffectiveQuery() != "hello" {
t.Errorf("query = %q", req.EffectiveQuery())
if messages.EffectiveQuery(&req) != "hello" {
t.Errorf("query = %q", messages.EffectiveQuery(&req))
}
if req.EnableRAG {
if req.EnableRag {
t.Error("EnableRAG should be false")
}
if req.SystemPrompt != "Be brief." {