ข้ามไปยังเนื้อหา

Tutorial: gRPC service

เนื้อหานี้ยังไม่ได้แปลเป็นภาษาไทย แสดงเป็นภาษาอังกฤษแทน

Cephalon.AspNetCore.Grpc is the transport adapter for gRPC. It handles unary and streaming methods, plugs into the same behavior pipeline as REST, and integrates with the host’s observability stack so traces propagate across the wire.

  • a gRPC service exposing GetProduct (unary) and WatchInventory (server streaming).
  • a proto contract shared between the service and a client console app.
  • mutual TLS via the included Kubernetes deploy script.
  • traces that flow from the calling client through the gRPC server into the database.
<PackageReference Include="Cephalon.AspNetCore.Grpc" />
Program.cs
builder.Services
.AddCephalonAspNetCore(options => options.EnableGrpc())
.AddModulesFromAssemblies(/* ... */);
public sealed class ProductsGrpcModule : GrpcBehaviorModuleBase
{
public override ModuleDescriptor Describe() => new("Acme.Store.Grpc.Products", "1.0.0", [Capability.Data]);
protected override void ConfigureGrpcServices(IGrpcBehaviorBuilder builder)
{
builder.MapService<ProductsGrpcService>();
}
}

The full step-by-step walkthrough is part of the next docs push. In the meantime: