金色时刻 · 15:48
让好资源,触手可及
AGENT SKILL

transport

transport 是面向软件开发的 Agent Skill,来自 HoangNguyen0403/agent-skills-standard。查看技能说明、操作步骤与使用约定,并通过原项目了解详细用法。

gRPC, RabbitMQ standards and Monorepo contracts.

SKILL.md

下载 MD ↓
nameNestJS Microservices
descriptiongRPC, RabbitMQ standards and Monorepo contracts.
metadata{"labels": ["nestjs", "microservices", "grpc", "rabbitmq"], "triggers": {"files": ["main.ts", "**/*.controller.ts"], "keywords": ["Transport.GRPC", "Transport.RMQ", "MicroserviceOptions"]}}

Microservices & Transport Standards

Priority: P0 (FOUNDATIONAL)

Microservices communication patterns and transport layer standards.

  • Synchronous (RPC): Use gRPC for low-latency, internal service-to-service calls.
  • Why: 10x faster than REST/JSON, centralized .proto contracts.
  • Asynchronous (Events): Use RabbitMQ or Kafka for decoupling domains.
  • Pattern: Fire-and-forget (emit()) for side effects (e.g., "UserCreated" -> "SendEmail").

Monorepo Architecture

  • Contracts:
  • Pattern: Store all DTOs, .proto files, and Interfaces in a Shared Library (libs/contracts).
  • Rule: Services never import code from other services. They only import from contracts.
  • Versioning: Semantic versioning of messages is mandatory. Never change a field type; add a new field.

Exception Handling

  • Propagation: Standard HttpException is lost over Rpc/Tcp.
  • Standard: Use RpcException and generic Filters.

typescript // Global RPC Filter @Catch() export class RpcExceptionFilter implements RpcExceptionFilter<RpcException> { catch(exception: RpcException, host: ArgumentsHost): Observable<any> { return throwError(() => exception.getError()); } }

Serialization

  • Message DTOs: Use class-validator just like HTTP.
  • Config: Apply useGlobalPipes(new ValidationPipe({ transform: true })) in the MicroserviceOptions setup, not just HTTP app setup.

来源:HoangNguyen0403/agent-skills-standard · MIT 许可 · 许可原文 · MD 为来源页保存的历史版本