浏览代码

chore: drop loadgen producer's redundant outer retry loop

The loadgen's Stream.Send wrapper already retries 3x on retriable
codes (Unavailable / ResourceExhausted / Internal) with backoff
based on the server's x-retry-after-ms header. The producer
goroutine was then checking the returned status code, sleeping 5ms
on retriable, and calling Stream.Send *again* (which would retry 3
more times internally) — so up to 8 attempts per alert, and the
result of the second Send was silently ignored on success.

Simplify: treat any non-nil error from Stream.Send as terminal for
this tick. Counter++ and exit the worker. The server still gets
the same retry budget via the wrapper; we just stop double-counting.

Also drop the now-unused google.golang.org/grpc/codes and
google.golang.org/grpc/status imports.
Luis Rosales 1 月之前
父节点
当前提交
a61fc6d397
共有 1 个文件被更改,包括 6 次插入15 次删除
  1. 6 15
      loadgen/cmd/grpc/main.go

+ 6 - 15
loadgen/cmd/grpc/main.go

@@ -33,8 +33,6 @@ import (
 	pbv1 "git3.techno-world.net/lrosales/broad-announce/gen/go/broadannounce/v1"
 	"git3.techno-world.net/lrosales/broad-announce/internal/alert"
 	"git3.techno-world.net/lrosales/broad-announce/loadgen/internal/pacer"
-	"google.golang.org/grpc/codes"
-	"google.golang.org/grpc/status"
 )
 
 type workerResult struct {
@@ -208,19 +206,12 @@ func runWorker(
 			case <-tickCh:
 				a := mkAlert("normal", companyFromKey(apiKey), sourceID, dedupePct, dedupeKey, payloadB)
 				if err := stream.Send(prodCtx, alertToProto(companyFromKey(apiKey), sourceID, a)); err != nil {
-					// Check if it's a retriable error.
-					st, _ := status.FromError(err)
-					if st.Code() == codes.ResourceExhausted || st.Code() == codes.Unavailable {
-						// Retry with backoff.
-						time.Sleep(5 * time.Millisecond)
-						if err := stream.Send(prodCtx, alertToProto(companyFromKey(apiKey), sourceID, a)); err != nil {
-							res.failed++
-							return
-						}
-					} else {
-						res.failed++
-						return
-					}
+					// stream.Send (loadgen wrapper) already retries 3x on
+					// retriable codes. Treat any error here as terminal
+					// for this tick. Counter + exit.
+					logger.Error("send failed", "err", err)
+					res.failed++
+					return
 				}
 				ackCh <- pendingAck{sentAt: time.Now(), dk: a.DedupeKey}
 				i++