Intent.AspNetCore.Grpc module generates high-performance gRPC services based on definitions in the Services Designer. gRPC is a modern, high-performance RPC framework ideal for microservices and mobile-to-backend communication.
Overview
gRPC uses Protocol Buffers (protobuf) as its Interface Definition Language (IDL) and provides features like bidirectional streaming, flow control, and efficient binary serialization. This module automatically generates .proto files and service implementations from your Intent Architect service models.What Gets Generated
Proto Files
Protocol Buffer definitions for your services:gRPC Service Implementation
Generated service classes:GrpcConfiguration
Configures gRPC services:Exception Interceptor
Handles exceptions gracefully:Key Features
High Performance
Binary protocol with efficient serialization
Streaming
Support for unary, server, client, and bidirectional streaming
Type Safety
Strong typing with auto-generated client code
Multi-Platform
Clients for .NET, Java, Python, Go, and more
Service Types
Unary RPC
Simple request-response:Server Streaming
Server streams multiple responses:Client Streaming
Client streams multiple requests:Bidirectional Streaming
Both client and server stream:Client Usage
.NET Client
Python Client
Authentication
JWT Authentication
Error Handling
Status Codes
gRPC uses standard status codes:| Code | Description | Use Case |
|---|---|---|
| OK | Success | Successful operation |
| CANCELLED | Operation cancelled | Client cancelled |
| INVALID_ARGUMENT | Invalid input | Validation failure |
| NOT_FOUND | Resource not found | Entity doesn’t exist |
| ALREADY_EXISTS | Resource exists | Duplicate creation |
| PERMISSION_DENIED | No permission | Authorization failure |
| UNAUTHENTICATED | Not authenticated | Missing/invalid token |
| RESOURCE_EXHAUSTED | Rate limited | Too many requests |
| UNIMPLEMENTED | Not implemented | Method not available |
| INTERNAL | Internal error | Server error |
| UNAVAILABLE | Service unavailable | Temporary failure |
Exception Handling
Performance Optimization
HTTP/2 Settings
Message Size Limits
Compression
Testing
Unit Tests
Integration Tests
Best Practices
API Design
API Design
- Use clear, consistent naming
- Version your proto files
- Document with comments
- Use well-known types (Timestamp, Duration, etc.)
Performance
Performance
- Use streaming for large datasets
- Enable compression
- Set appropriate message size limits
- Use connection pooling
Error Handling
Error Handling
- Use appropriate status codes
- Include detailed error messages
- Implement proper exception handling
- Log all errors
Security
Security
- Always use TLS in production
- Implement authentication
- Validate all inputs
- Use interceptors for cross-cutting concerns
gRPC vs REST
| Aspect | gRPC | REST |
|---|---|---|
| Protocol | HTTP/2 | HTTP/1.1 |
| Format | Protocol Buffers (binary) | JSON (text) |
| Performance | Faster, less bandwidth | Slower, more bandwidth |
| Streaming | Built-in | Limited |
| Browser Support | Limited (gRPC-Web needed) | Full |
| Tooling | Code generation | OpenAPI |
| Human Readable | No | Yes |
| Best For | Microservices, mobile apps | Public APIs, web apps |
Installation
Dependencies
Intent.Common.CSharpIntent.Modelers.ServicesIntent.OutputManager.RoslynWeaver
Next Steps
Controllers
Compare with REST API controllers
MediatR
Dispatch gRPC calls to handlers
Security
Secure gRPC services
