Skip to main content

gRPC Services in .NET

Build high-performance gRPC services in .NET — proto design, server streaming, interceptors, error handling, and client generation.

Vul de plaatshouders in

Edit the values, then copy your finished prompt.

Jouw Prompt
prompt.txt

                                

What this prompt does

This prompt builds gRPC services for a [service_purpose] in [dotnet_version], covering the full contract-to-client path. It asks for a [proto_file_name].proto with [method_count] methods across unary and streaming styles, message types for [message_types], a server implementation with [business_logic], correct status-code error handling, interceptors for [interceptor_purposes], server streaming for [streaming_scenario], a typed client with [client_config], health checks, and HTTP/2 tuning for [performance_target].

The variables anchor the answer to a real service. [message_types] and [business_logic] define the proto contract and what the methods actually do, while [interceptor_purposes] and [client_config] shape cross-cutting concerns like logging, JWT validation, deadlines, and retries. [performance_target] pushes the model to address HTTP/2 settings, connection pooling, and compression rather than leaving performance vague. Because the prompt covers both the proto contract and the generated client, you avoid the common trap of a beautifully designed service that no one can call cleanly: deadline propagation and retry policy on the client side are treated as first-class, not afterthoughts.

When to use it

  • Services need high-throughput, low-latency communication and HTTP/JSON is the bottleneck
  • Designing a proto contract with both unary and streaming methods
  • You want correct gRPC status-code mapping from domain exceptions, not generic Unknown errors
  • Adding interceptors for [interceptor_purposes] like correlation IDs and auth
  • Implementing server streaming for [streaming_scenario] with cancellation handling
  • Preparing gRPC health checks for Kubernetes readiness probes

Example output

You get a proto file defining the [message_types] and service, generated-then-implemented C# service classes with async methods and CancellationToken support, an exception-to-status-code mapping, interceptor classes, a server streaming method, a typed client configured per [client_config], a health check registration, and HTTP/2 performance settings. It is organized as proto plus server plus client plus ops, each with explanation.

Pro tips

  • Make [message_types] reflect your real domain; vague names like Request and Response produce a proto you will rewrite immediately
  • Be explicit in [business_logic] so the server methods do something concrete rather than returning placeholders
  • Spell out [performance_target] (for example a p99 latency under load) so the model justifies the HTTP/2 and compression choices instead of guessing
  • Set realistic deadlines in [client_config] — a missing deadline is the classic cause of gRPC calls hanging forever
  • Map domain exceptions to specific status codes (NotFound, InvalidArgument, PermissionDenied); returning Unknown for everything makes clients unable to react
  • Don't skip the health-check step if you deploy to Kubernetes — readiness probes need the gRPC health protocol to route traffic correctly
  • Keep [interceptor_purposes] focused on cross-cutting concerns like logging, auth, and metrics; business rules belong in the service method, not an interceptor
  • For [streaming_scenario], make sure cancellation is honored — a client that disconnects mid-stream should stop server work promptly, or you leak resources under load

Frequently Asked Questions

Does this cover server streaming or only unary gRPC calls?
It covers both. Step 1 asks for `[method_count]` methods spanning unary, server streaming, and client streaming, and step 5 implements server streaming for `[streaming_scenario]` with backpressure and graceful cancellation. So you get streaming patterns, not just request-response.
How does the prompt handle errors in gRPC?
It maps domain exceptions to the correct gRPC status codes like NotFound, InvalidArgument, and PermissionDenied, and attaches rich error details using google.rpc.Status. This is important because returning a generic Unknown status leaves clients unable to distinguish a bad request from a missing resource.
Will it set up the client as well as the server?
Yes. Step 6 configures a typed gRPC client per `[client_config]`, including channel management, deadline propagation, and retry policies via the client factory. You get both ends of the contract rather than just the service implementation.
Is the health check needed for Kubernetes?
If you deploy to Kubernetes, yes. The gRPC health checking protocol lets readiness and liveness probes know when the service can accept traffic. Without it, Kubernetes cannot reliably tell whether your gRPC service is ready, which can route requests to an unready pod.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

Meer in C# & .NET Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support