Назад към всички

rpc

// Guidelines for RPC interface design, resilience, and tracing.

$ git log --oneline --stat
stars:2
forks:0
updated:February 26, 2026
SKILL.mdreadonly
SKILL.md Frontmatter
namerpc
descriptionGuidelines for RPC interface design, resilience, and tracing.

RPC

Design

  • Context: Every RPC entry point or client call MUST accept context.Context as the first argument.
  • Tracing: All RPCs MUST be instrumented with OpenTelemetry.
    • Server: Extract context, start span.
    • Client: Inject context, start span.

Resilience

Timeouts

Set a deadline on every outgoing request.

ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()
ScenarioTimeout
Inter-service (same datacenter)2s
External API5-10s
User-facing1s
Background jobs30-60s

Retries

Use exponential backoff with jitter for transient failures.

  • gRPC: Use grpc_retry middleware.
  • HTTP: Use go-retryablehttp.