grpc-services
gRPC service development in .NET for high-performance inter-service communication
What this skill does
# gRPC Services in .NET
## Proto File
```protobuf
syntax = "proto3";
option csharp_namespace = "MyApp.Grpc";
package catalog;
service CatalogService {
rpc GetProduct (GetProductRequest) returns (ProductResponse);
rpc ListProducts (ListProductsRequest) returns (ListProductsResponse);
rpc CreateProduct (CreateProductRequest) returns (ProductResponse);
rpc StreamProducts (StreamRequest) returns (stream ProductResponse);
}
message GetProductRequest { int32 id = 1; }
message ListProductsRequest {
int32 page = 1;
int32 page_size = 2;
string search = 3;
}
message ListProductsResponse {
repeated ProductResponse products = 1;
int32 total_count = 2;
}
message CreateProductRequest {
string name = 1;
string description = 2;
double price = 3;
}
message ProductResponse {
int32 id = 1;
string name = 2;
string description = 3;
double price = 4;
}
message StreamRequest { string filter = 1; }
```
## Service Implementation
```csharp
public sealed class CatalogGrpcService(ICatalogService catalog, ILogger<CatalogGrpcService> logger)
: CatalogService.CatalogServiceBase
{
public override async Task<ProductResponse> GetProduct(
GetProductRequest request, ServerCallContext context)
{
var product = await catalog.GetByIdAsync(request.Id, context.CancellationToken)
?? throw new RpcException(new Status(StatusCode.NotFound, $"Product {request.Id} not found"));
return MapToResponse(product);
}
public override async Task StreamProducts(
StreamRequest request, IServerStreamWriter<ProductResponse> responseStream, ServerCallContext context)
{
await foreach (var product in catalog.StreamAsync(request.Filter, context.CancellationToken))
{
await responseStream.WriteAsync(MapToResponse(product));
}
}
}
```
## Server Setup
```csharp
builder.Services.AddGrpc();
app.MapGrpcService<CatalogGrpcService>();
```
## Client (with Aspire)
```csharp
builder.Services.AddGrpcClient<CatalogService.CatalogServiceClient>(o =>
{
o.Address = new("https+http://catalog-api");
})
.AddStandardResilienceHandler();
```
## gRPC vs REST Decision Matrix (from official docs)
| Aspect | gRPC | REST/HTTP |
|--------|------|----------|
| Serialization | Protocol Buffers (binary) | JSON (text) |
| Protocol | HTTP/2 | HTTP/1.1 or HTTP/2 |
| Payload size | Small, compressed | Larger, human-readable |
| Latency | Low (~10x faster) | Higher |
| Browser support | Limited (gRPC-Web) | Full |
| Code generation | Automatic (contract-first) | Manual |
| Streaming | Native, bidirectional | Limited |
| Debugging | Binary (harder) | Easy (HTTP tools) |
| Use case | Microservices, real-time | Public APIs, browsers |
## All 4 RPC Patterns (from official docs)
### Client Streaming
```csharp
// Stream of requests → single response
public override async Task<HelloReply> LotsOfGreetings(
IAsyncStreamReader<HelloRequest> requestStream, ServerCallContext context)
{
var count = 0;
await foreach (var request in requestStream.ReadAllAsync())
{
count++;
}
return new HelloReply { Message = $"Processed {count} greetings" };
}
```
### Bidirectional Streaming
```csharp
// Stream requests ↔ stream responses simultaneously
public override async Task BidiHello(
IAsyncStreamReader<HelloRequest> requestStream,
IServerStreamWriter<HelloReply> responseStream,
ServerCallContext context)
{
await foreach (var request in requestStream.ReadAllAsync())
{
await responseStream.WriteAsync(new HelloReply
{
Message = $"Echo: {request.Name}"
});
}
}
```
## Project Setup (from official docs)
```xml
<!-- .csproj -->
<ItemGroup>
<Protobuf Include="Protos\greet.proto" />
</ItemGroup>
```
```bash
dotnet add package Grpc.AspNetCore
dotnet add package Grpc.Tools
```
## Best Practices
- Use gRPC for internal service-to-service communication
- Use REST/HTTP for external APIs (browser compatibility)
- Use server streaming for large result sets
- Use `Deadline` for request timeouts
- Use interceptors for cross-cutting concerns (logging, auth)
- Add `.proto` files to `<Protobuf>` item group in .csproj
- Binary format = harder debugging; use gRPC reflection for tooling
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.