Compare commits
2 Commits
81581337cd
...
v0.1.3
| Author | SHA1 | Date | |
|---|---|---|---|
| 9876cb9388 | |||
| 39673d31b8 |
@@ -17,20 +17,22 @@ jobs:
|
|||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up uv
|
- name: Set up Go
|
||||||
run: curl -LsSf https://astral.sh/uv/install.sh | sh && echo "$HOME/.local/bin" >> $GITHUB_PATH
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version-file: go.mod
|
||||||
|
cache: true
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Run go vet
|
||||||
run: uv python install 3.13
|
run: go vet ./...
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install golangci-lint
|
||||||
run: uv sync --frozen --extra dev
|
run: |
|
||||||
|
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b "$(go env GOPATH)/bin"
|
||||||
|
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
|
||||||
|
|
||||||
- name: Run ruff check
|
- name: Run golangci-lint
|
||||||
run: uv run ruff check .
|
run: golangci-lint run ./...
|
||||||
|
|
||||||
- name: Run ruff format check
|
|
||||||
run: uv run ruff format --check .
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
name: Test
|
name: Test
|
||||||
@@ -39,17 +41,20 @@ jobs:
|
|||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up uv
|
- name: Set up Go
|
||||||
run: curl -LsSf https://astral.sh/uv/install.sh | sh && echo "$HOME/.local/bin" >> $GITHUB_PATH
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version-file: go.mod
|
||||||
|
cache: true
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Verify dependencies
|
||||||
run: uv python install 3.13
|
run: go mod verify
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Build
|
||||||
run: uv sync --frozen --extra dev
|
run: go build -v ./...
|
||||||
|
|
||||||
- name: Run tests with coverage
|
- name: Run tests
|
||||||
run: uv run pytest --cov=handler_base --cov-report=xml --cov-report=term
|
run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
|
||||||
|
|
||||||
release:
|
release:
|
||||||
name: Release
|
name: Release
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ resp, err := h.client.Do(req)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("http %s %s: %w", req.Method, req.URL.Path, err)
|
return nil, fmt.Errorf("http %s %s: %w", req.Method, req.URL.Path, err)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer func() { _ = resp.Body.Close() }()
|
||||||
|
|
||||||
buf := getBuf()
|
buf := getBuf()
|
||||||
defer putBuf(buf)
|
defer putBuf(buf)
|
||||||
@@ -420,7 +420,6 @@ type MilvusClient struct {
|
|||||||
Host string
|
Host string
|
||||||
Port int
|
Port int
|
||||||
Collection string
|
Collection string
|
||||||
connected bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewMilvusClient creates a Milvus client.
|
// NewMilvusClient creates a Milvus client.
|
||||||
|
|||||||
@@ -90,14 +90,14 @@ func TestEmbeddingsClient_Embed(t *testing.T) {
|
|||||||
t.Errorf("method = %s, want POST", r.Method)
|
t.Errorf("method = %s, want POST", r.Method)
|
||||||
}
|
}
|
||||||
var req map[string]any
|
var req map[string]any
|
||||||
json.NewDecoder(r.Body).Decode(&req)
|
_ = json.NewDecoder(r.Body).Decode(&req)
|
||||||
input, _ := req["input"].([]any)
|
input, _ := req["input"].([]any)
|
||||||
if len(input) != 2 {
|
if len(input) != 2 {
|
||||||
t.Errorf("input len = %d, want 2", len(input))
|
t.Errorf("input len = %d, want 2", len(input))
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
json.NewEncoder(w).Encode(map[string]any{
|
_ = json.NewEncoder(w).Encode(map[string]any{
|
||||||
"data": []map[string]any{
|
"data": []map[string]any{
|
||||||
{"embedding": []float64{0.1, 0.2, 0.3}},
|
{"embedding": []float64{0.1, 0.2, 0.3}},
|
||||||
{"embedding": []float64{0.4, 0.5, 0.6}},
|
{"embedding": []float64{0.4, 0.5, 0.6}},
|
||||||
@@ -121,7 +121,7 @@ func TestEmbeddingsClient_Embed(t *testing.T) {
|
|||||||
|
|
||||||
func TestEmbeddingsClient_EmbedSingle(t *testing.T) {
|
func TestEmbeddingsClient_EmbedSingle(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
json.NewEncoder(w).Encode(map[string]any{
|
_ = json.NewEncoder(w).Encode(map[string]any{
|
||||||
"data": []map[string]any{
|
"data": []map[string]any{
|
||||||
{"embedding": []float64{1.0, 2.0}},
|
{"embedding": []float64{1.0, 2.0}},
|
||||||
},
|
},
|
||||||
@@ -141,7 +141,7 @@ func TestEmbeddingsClient_EmbedSingle(t *testing.T) {
|
|||||||
|
|
||||||
func TestEmbeddingsClient_EmbedEmpty(t *testing.T) {
|
func TestEmbeddingsClient_EmbedEmpty(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
json.NewEncoder(w).Encode(map[string]any{"data": []any{}})
|
_ = json.NewEncoder(w).Encode(map[string]any{"data": []any{}})
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
@@ -175,11 +175,11 @@ func TestEmbeddingsClient_Health(t *testing.T) {
|
|||||||
func TestRerankerClient_Rerank(t *testing.T) {
|
func TestRerankerClient_Rerank(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
var req map[string]any
|
var req map[string]any
|
||||||
json.NewDecoder(r.Body).Decode(&req)
|
_ = json.NewDecoder(r.Body).Decode(&req)
|
||||||
if req["query"] != "test query" {
|
if req["query"] != "test query" {
|
||||||
t.Errorf("query = %v", req["query"])
|
t.Errorf("query = %v", req["query"])
|
||||||
}
|
}
|
||||||
json.NewEncoder(w).Encode(map[string]any{
|
_ = json.NewEncoder(w).Encode(map[string]any{
|
||||||
"results": []map[string]any{
|
"results": []map[string]any{
|
||||||
{"index": 1, "relevance_score": 0.95},
|
{"index": 1, "relevance_score": 0.95},
|
||||||
{"index": 0, "relevance_score": 0.80},
|
{"index": 0, "relevance_score": 0.80},
|
||||||
@@ -207,7 +207,7 @@ func TestRerankerClient_Rerank(t *testing.T) {
|
|||||||
|
|
||||||
func TestRerankerClient_RerankFallbackScore(t *testing.T) {
|
func TestRerankerClient_RerankFallbackScore(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
json.NewEncoder(w).Encode(map[string]any{
|
_ = json.NewEncoder(w).Encode(map[string]any{
|
||||||
"results": []map[string]any{
|
"results": []map[string]any{
|
||||||
{"index": 0, "score": 0.77, "relevance_score": 0}, // some APIs only set score
|
{"index": 0, "score": 0.77, "relevance_score": 0}, // some APIs only set score
|
||||||
},
|
},
|
||||||
@@ -235,13 +235,13 @@ func TestLLMClient_Generate(t *testing.T) {
|
|||||||
t.Errorf("path = %q", r.URL.Path)
|
t.Errorf("path = %q", r.URL.Path)
|
||||||
}
|
}
|
||||||
var req map[string]any
|
var req map[string]any
|
||||||
json.NewDecoder(r.Body).Decode(&req)
|
_ = json.NewDecoder(r.Body).Decode(&req)
|
||||||
msgs, _ := req["messages"].([]any)
|
msgs, _ := req["messages"].([]any)
|
||||||
if len(msgs) == 0 {
|
if len(msgs) == 0 {
|
||||||
t.Error("no messages in request")
|
t.Error("no messages in request")
|
||||||
}
|
}
|
||||||
|
|
||||||
json.NewEncoder(w).Encode(map[string]any{
|
_ = json.NewEncoder(w).Encode(map[string]any{
|
||||||
"choices": []map[string]any{
|
"choices": []map[string]any{
|
||||||
{"message": map[string]any{"content": "Paris is the capital of France."}},
|
{"message": map[string]any{"content": "Paris is the capital of France."}},
|
||||||
},
|
},
|
||||||
@@ -262,13 +262,13 @@ func TestLLMClient_Generate(t *testing.T) {
|
|||||||
func TestLLMClient_GenerateWithContext(t *testing.T) {
|
func TestLLMClient_GenerateWithContext(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
var req map[string]any
|
var req map[string]any
|
||||||
json.NewDecoder(r.Body).Decode(&req)
|
_ = json.NewDecoder(r.Body).Decode(&req)
|
||||||
msgs, _ := req["messages"].([]any)
|
msgs, _ := req["messages"].([]any)
|
||||||
// Should have system + user message
|
// Should have system + user message
|
||||||
if len(msgs) != 2 {
|
if len(msgs) != 2 {
|
||||||
t.Errorf("expected 2 messages, got %d", len(msgs))
|
t.Errorf("expected 2 messages, got %d", len(msgs))
|
||||||
}
|
}
|
||||||
json.NewEncoder(w).Encode(map[string]any{
|
_ = json.NewEncoder(w).Encode(map[string]any{
|
||||||
"choices": []map[string]any{
|
"choices": []map[string]any{
|
||||||
{"message": map[string]any{"content": "answer with context"}},
|
{"message": map[string]any{"content": "answer with context"}},
|
||||||
},
|
},
|
||||||
@@ -288,7 +288,7 @@ func TestLLMClient_GenerateWithContext(t *testing.T) {
|
|||||||
|
|
||||||
func TestLLMClient_GenerateNoChoices(t *testing.T) {
|
func TestLLMClient_GenerateNoChoices(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
json.NewEncoder(w).Encode(map[string]any{"choices": []any{}})
|
_ = json.NewEncoder(w).Encode(map[string]any{"choices": []any{}})
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
@@ -312,7 +312,7 @@ func TestTTSClient_Synthesize(t *testing.T) {
|
|||||||
if r.URL.Query().Get("text") != "hello world" {
|
if r.URL.Query().Get("text") != "hello world" {
|
||||||
t.Errorf("text = %q", r.URL.Query().Get("text"))
|
t.Errorf("text = %q", r.URL.Query().Get("text"))
|
||||||
}
|
}
|
||||||
w.Write(expected)
|
_, _ = w.Write(expected)
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
@@ -331,7 +331,7 @@ func TestTTSClient_SynthesizeWithSpeaker(t *testing.T) {
|
|||||||
if r.URL.Query().Get("speaker_id") != "alice" {
|
if r.URL.Query().Get("speaker_id") != "alice" {
|
||||||
t.Errorf("speaker_id = %q", r.URL.Query().Get("speaker_id"))
|
t.Errorf("speaker_id = %q", r.URL.Query().Get("speaker_id"))
|
||||||
}
|
}
|
||||||
w.Write([]byte{0x01})
|
_, _ = w.Write([]byte{0x01})
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
@@ -365,7 +365,7 @@ func TestSTTClient_Transcribe(t *testing.T) {
|
|||||||
t.Errorf("file size = %d, want 100", len(data))
|
t.Errorf("file size = %d, want 100", len(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
json.NewEncoder(w).Encode(map[string]string{"text": "hello world"})
|
_ = json.NewEncoder(w).Encode(map[string]string{"text": "hello world"})
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
@@ -384,7 +384,7 @@ func TestSTTClient_TranscribeTranslate(t *testing.T) {
|
|||||||
if r.URL.Path != "/v1/audio/translations" {
|
if r.URL.Path != "/v1/audio/translations" {
|
||||||
t.Errorf("path = %q, want /v1/audio/translations", r.URL.Path)
|
t.Errorf("path = %q, want /v1/audio/translations", r.URL.Path)
|
||||||
}
|
}
|
||||||
json.NewEncoder(w).Encode(map[string]string{"text": "translated"})
|
_ = json.NewEncoder(w).Encode(map[string]string{"text": "translated"})
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
@@ -406,7 +406,7 @@ func TestSTTClient_TranscribeTranslate(t *testing.T) {
|
|||||||
func TestHTTPError4xx(t *testing.T) {
|
func TestHTTPError4xx(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.WriteHeader(422)
|
w.WriteHeader(422)
|
||||||
w.Write([]byte(`{"error": "bad input"}`))
|
_, _ = w.Write([]byte(`{"error": "bad input"}`))
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
@@ -423,7 +423,7 @@ func TestHTTPError4xx(t *testing.T) {
|
|||||||
func TestHTTPError5xx(t *testing.T) {
|
func TestHTTPError5xx(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.WriteHeader(500)
|
w.WriteHeader(500)
|
||||||
w.Write([]byte("internal server error"))
|
_, _ = w.Write([]byte("internal server error"))
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
@@ -467,8 +467,8 @@ func TestBuildMessages(t *testing.T) {
|
|||||||
|
|
||||||
func BenchmarkPostJSON(b *testing.B) {
|
func BenchmarkPostJSON(b *testing.B) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
io.Copy(io.Discard, r.Body)
|
_, _ = io.Copy(io.Discard, r.Body)
|
||||||
w.Write([]byte(`{"ok":true}`))
|
_, _ = w.Write([]byte(`{"ok":true}`))
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
@@ -482,7 +482,7 @@ func BenchmarkPostJSON(b *testing.B) {
|
|||||||
|
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for b.Loop() {
|
for b.Loop() {
|
||||||
c.postJSON(ctx, "/test", payload)
|
_, _ = c.postJSON(ctx, "/test", payload)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,8 +66,8 @@ func TestCallbackRegistration(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Verify setup/teardown work when called directly.
|
// Verify setup/teardown work when called directly.
|
||||||
h.onSetup(context.Background())
|
_ = h.onSetup(context.Background())
|
||||||
h.onTeardown(context.Background())
|
_ = h.onTeardown(context.Background())
|
||||||
if !setupCalled || !teardownCalled {
|
if !setupCalled || !teardownCalled {
|
||||||
t.Error("callbacks should have been invoked")
|
t.Error("callbacks should have been invoked")
|
||||||
}
|
}
|
||||||
@@ -290,7 +290,7 @@ func BenchmarkWrapTypedHandler(b *testing.B) {
|
|||||||
h := New("ai.test", cfg)
|
h := New("ai.test", cfg)
|
||||||
h.OnTypedMessage(func(ctx context.Context, msg *nats.Msg) (any, error) {
|
h.OnTypedMessage(func(ctx context.Context, msg *nats.Msg) (any, error) {
|
||||||
var req benchReq
|
var req benchReq
|
||||||
msgpack.Unmarshal(msg.Data, &req)
|
_ = msgpack.Unmarshal(msg.Data, &req)
|
||||||
return map[string]any{"ok": true}, nil
|
return map[string]any{"ok": true}, nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import (
|
|||||||
"log/slog"
|
"log/slog"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sync/atomic"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -22,7 +21,6 @@ type Server struct {
|
|||||||
readyPath string
|
readyPath string
|
||||||
readyCheck ReadyFunc
|
readyCheck ReadyFunc
|
||||||
srv *http.Server
|
srv *http.Server
|
||||||
ready atomic.Bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates a health server on the given port.
|
// New creates a health server on the given port.
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ func TestHealthEndpoint(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("health request failed: %v", err)
|
t.Fatalf("health request failed: %v", err)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer func() { _ = resp.Body.Close() }()
|
||||||
|
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
t.Errorf("expected 200, got %d", resp.StatusCode)
|
t.Errorf("expected 200, got %d", resp.StatusCode)
|
||||||
@@ -42,7 +42,7 @@ func TestReadyEndpointDefault(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("ready request failed: %v", err)
|
t.Fatalf("ready request failed: %v", err)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer func() { _ = resp.Body.Close() }()
|
||||||
|
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
t.Errorf("expected 200, got %d", resp.StatusCode)
|
t.Errorf("expected 200, got %d", resp.StatusCode)
|
||||||
@@ -60,7 +60,7 @@ func TestReadyEndpointNotReady(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("ready request failed: %v", err)
|
t.Fatalf("ready request failed: %v", err)
|
||||||
}
|
}
|
||||||
resp.Body.Close()
|
_ = resp.Body.Close()
|
||||||
if resp.StatusCode != 503 {
|
if resp.StatusCode != 503 {
|
||||||
t.Errorf("expected 503 when not ready, got %d", resp.StatusCode)
|
t.Errorf("expected 503 when not ready, got %d", resp.StatusCode)
|
||||||
}
|
}
|
||||||
@@ -70,7 +70,7 @@ func TestReadyEndpointNotReady(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("ready request failed: %v", err)
|
t.Fatalf("ready request failed: %v", err)
|
||||||
}
|
}
|
||||||
resp2.Body.Close()
|
_ = resp2.Body.Close()
|
||||||
if resp2.StatusCode != 200 {
|
if resp2.StatusCode != 200 {
|
||||||
t.Errorf("expected 200 when ready, got %d", resp2.StatusCode)
|
t.Errorf("expected 200 when ready, got %d", resp2.StatusCode)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ func BenchmarkEncode_ChatRequest_MsgpackMap(b *testing.B) {
|
|||||||
data := chatRequestMap()
|
data := chatRequestMap()
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for b.Loop() {
|
for b.Loop() {
|
||||||
msgpack.Marshal(data)
|
_, _ = msgpack.Marshal(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,7 +186,7 @@ func BenchmarkEncode_ChatRequest_MsgpackStruct(b *testing.B) {
|
|||||||
data := chatRequestStruct()
|
data := chatRequestStruct()
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for b.Loop() {
|
for b.Loop() {
|
||||||
msgpack.Marshal(data)
|
_, _ = msgpack.Marshal(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +194,7 @@ func BenchmarkEncode_ChatRequest_Protobuf(b *testing.B) {
|
|||||||
data := chatRequestProto()
|
data := chatRequestProto()
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for b.Loop() {
|
for b.Loop() {
|
||||||
proto.Marshal(data)
|
_, _ = proto.Marshal(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,7 +202,7 @@ func BenchmarkEncode_VoiceResponse_MsgpackMap(b *testing.B) {
|
|||||||
data := voiceResponseMap()
|
data := voiceResponseMap()
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for b.Loop() {
|
for b.Loop() {
|
||||||
msgpack.Marshal(data)
|
_, _ = msgpack.Marshal(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,7 +210,7 @@ func BenchmarkEncode_VoiceResponse_MsgpackStruct(b *testing.B) {
|
|||||||
data := voiceResponseStruct()
|
data := voiceResponseStruct()
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for b.Loop() {
|
for b.Loop() {
|
||||||
msgpack.Marshal(data)
|
_, _ = msgpack.Marshal(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,7 +218,7 @@ func BenchmarkEncode_VoiceResponse_Protobuf(b *testing.B) {
|
|||||||
data := voiceResponseProto()
|
data := voiceResponseProto()
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for b.Loop() {
|
for b.Loop() {
|
||||||
proto.Marshal(data)
|
_, _ = proto.Marshal(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,7 +226,7 @@ func BenchmarkEncode_TTSChunk_MsgpackMap(b *testing.B) {
|
|||||||
data := ttsChunkMap()
|
data := ttsChunkMap()
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for b.Loop() {
|
for b.Loop() {
|
||||||
msgpack.Marshal(data)
|
_, _ = msgpack.Marshal(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,7 +234,7 @@ func BenchmarkEncode_TTSChunk_MsgpackStruct(b *testing.B) {
|
|||||||
data := ttsChunkStruct()
|
data := ttsChunkStruct()
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for b.Loop() {
|
for b.Loop() {
|
||||||
msgpack.Marshal(data)
|
_, _ = msgpack.Marshal(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,7 +242,7 @@ func BenchmarkEncode_TTSChunk_Protobuf(b *testing.B) {
|
|||||||
data := ttsChunkProto()
|
data := ttsChunkProto()
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for b.Loop() {
|
for b.Loop() {
|
||||||
proto.Marshal(data)
|
_, _ = proto.Marshal(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,7 +255,7 @@ func BenchmarkDecode_ChatRequest_MsgpackMap(b *testing.B) {
|
|||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for b.Loop() {
|
for b.Loop() {
|
||||||
var m map[string]any
|
var m map[string]any
|
||||||
msgpack.Unmarshal(encoded, &m)
|
_ = msgpack.Unmarshal(encoded, &m)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,7 +264,7 @@ func BenchmarkDecode_ChatRequest_MsgpackStruct(b *testing.B) {
|
|||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for b.Loop() {
|
for b.Loop() {
|
||||||
var m ChatRequest
|
var m ChatRequest
|
||||||
msgpack.Unmarshal(encoded, &m)
|
_ = msgpack.Unmarshal(encoded, &m)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,7 +273,7 @@ func BenchmarkDecode_ChatRequest_Protobuf(b *testing.B) {
|
|||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for b.Loop() {
|
for b.Loop() {
|
||||||
var m pb.ChatRequest
|
var m pb.ChatRequest
|
||||||
proto.Unmarshal(encoded, &m)
|
_ = proto.Unmarshal(encoded, &m)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,7 +282,7 @@ func BenchmarkDecode_VoiceResponse_MsgpackMap(b *testing.B) {
|
|||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for b.Loop() {
|
for b.Loop() {
|
||||||
var m map[string]any
|
var m map[string]any
|
||||||
msgpack.Unmarshal(encoded, &m)
|
_ = msgpack.Unmarshal(encoded, &m)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,7 +291,7 @@ func BenchmarkDecode_VoiceResponse_MsgpackStruct(b *testing.B) {
|
|||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for b.Loop() {
|
for b.Loop() {
|
||||||
var m VoiceResponse
|
var m VoiceResponse
|
||||||
msgpack.Unmarshal(encoded, &m)
|
_ = msgpack.Unmarshal(encoded, &m)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,7 +300,7 @@ func BenchmarkDecode_VoiceResponse_Protobuf(b *testing.B) {
|
|||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for b.Loop() {
|
for b.Loop() {
|
||||||
var m pb.VoiceResponse
|
var m pb.VoiceResponse
|
||||||
proto.Unmarshal(encoded, &m)
|
_ = proto.Unmarshal(encoded, &m)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,7 +309,7 @@ func BenchmarkDecode_TTSChunk_MsgpackMap(b *testing.B) {
|
|||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for b.Loop() {
|
for b.Loop() {
|
||||||
var m map[string]any
|
var m map[string]any
|
||||||
msgpack.Unmarshal(encoded, &m)
|
_ = msgpack.Unmarshal(encoded, &m)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,7 +318,7 @@ func BenchmarkDecode_TTSChunk_MsgpackStruct(b *testing.B) {
|
|||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for b.Loop() {
|
for b.Loop() {
|
||||||
var m TTSAudioChunk
|
var m TTSAudioChunk
|
||||||
msgpack.Unmarshal(encoded, &m)
|
_ = msgpack.Unmarshal(encoded, &m)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,7 +327,7 @@ func BenchmarkDecode_TTSChunk_Protobuf(b *testing.B) {
|
|||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for b.Loop() {
|
for b.Loop() {
|
||||||
var m pb.TTSAudioChunk
|
var m pb.TTSAudioChunk
|
||||||
proto.Unmarshal(encoded, &m)
|
_ = proto.Unmarshal(encoded, &m)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,7 +341,7 @@ func BenchmarkRoundtrip_ChatRequest_MsgpackMap(b *testing.B) {
|
|||||||
for b.Loop() {
|
for b.Loop() {
|
||||||
enc, _ := msgpack.Marshal(data)
|
enc, _ := msgpack.Marshal(data)
|
||||||
var dec map[string]any
|
var dec map[string]any
|
||||||
msgpack.Unmarshal(enc, &dec)
|
_ = msgpack.Unmarshal(enc, &dec)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,7 +351,7 @@ func BenchmarkRoundtrip_ChatRequest_MsgpackStruct(b *testing.B) {
|
|||||||
for b.Loop() {
|
for b.Loop() {
|
||||||
enc, _ := msgpack.Marshal(data)
|
enc, _ := msgpack.Marshal(data)
|
||||||
var dec ChatRequest
|
var dec ChatRequest
|
||||||
msgpack.Unmarshal(enc, &dec)
|
_ = msgpack.Unmarshal(enc, &dec)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -361,7 +361,7 @@ func BenchmarkRoundtrip_ChatRequest_Protobuf(b *testing.B) {
|
|||||||
for b.Loop() {
|
for b.Loop() {
|
||||||
enc, _ := proto.Marshal(data)
|
enc, _ := proto.Marshal(data)
|
||||||
var dec pb.ChatRequest
|
var dec pb.ChatRequest
|
||||||
proto.Unmarshal(enc, &dec)
|
_ = proto.Unmarshal(enc, &dec)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ func BenchmarkEncodeMap(b *testing.B) {
|
|||||||
"top_k": 10,
|
"top_k": 10,
|
||||||
}
|
}
|
||||||
for b.Loop() {
|
for b.Loop() {
|
||||||
msgpack.Marshal(data)
|
_, _ = msgpack.Marshal(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,7 +212,7 @@ func BenchmarkEncodeStruct(b *testing.B) {
|
|||||||
Active: true,
|
Active: true,
|
||||||
}
|
}
|
||||||
for b.Loop() {
|
for b.Loop() {
|
||||||
msgpack.Marshal(data)
|
_, _ = msgpack.Marshal(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,7 +226,7 @@ func BenchmarkDecodeMap(b *testing.B) {
|
|||||||
})
|
})
|
||||||
for b.Loop() {
|
for b.Loop() {
|
||||||
var m map[string]any
|
var m map[string]any
|
||||||
msgpack.Unmarshal(raw, &m)
|
_ = msgpack.Unmarshal(raw, &m)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,7 +239,7 @@ func BenchmarkDecodeStruct(b *testing.B) {
|
|||||||
})
|
})
|
||||||
for b.Loop() {
|
for b.Loop() {
|
||||||
var m testMessage
|
var m testMessage
|
||||||
msgpack.Unmarshal(raw, &m)
|
_ = msgpack.Unmarshal(raw, &m)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,6 +251,6 @@ func BenchmarkDecodeAudio32KB(b *testing.B) {
|
|||||||
})
|
})
|
||||||
for b.Loop() {
|
for b.Loop() {
|
||||||
var m audioMessage
|
var m audioMessage
|
||||||
msgpack.Unmarshal(raw, &m)
|
_ = msgpack.Unmarshal(raw, &m)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user