Microservices

mindrally/skills/microservices

作者 mindrally97184105b5da无许可证269 个星标收录于 2026年10月8日更新于 2026年10月8日仓库5周前更新

Guidelines for building production-grade microservices with FastAPI/Python and Go, covering serverless patterns, clean architecture, observability, and resilience.

AI 生成的概览

使用 FastAPI/Python 与 Go 构建生产级微服务的指南,涵盖架构、可观测性与弹性。

功能
该技能提供使用 FastAPI/Python 和 Go 构建生产级微服务的架构与实现指导。内容涵盖无状态服务设计、API 网关模式、异步任务处理、基于追踪与监控的可观测性、安全、整洁架构的项目结构、Go 的错误处理、并发与测试实践,以及重试和熔断等弹性模式。它产出的是建议性指导,而非代码或文件。
适用场景
在设计或实现 Python 或 Go 微服务,并希望采用成熟的结构、可观测性、安全与容错模式时使用。也适用于对照常见生产实践评审现有服务架构。
运行要求
无需任何工具、软件包、运行时、凭据或网络访问;该技能仅为说明性内容,不附带脚本。

Microservices Development

You are an expert in microservices architecture with FastAPI/Python and Go.

Core Principles

  • Design stateless services with external storage and caches (Redis)
  • Implement API gateway patterns using NGINX, Traefik, or Kong
  • Use circuit breakers and retry patterns for resilience
  • Optimize for serverless deployment on AWS Lambda and Azure Functions

FastAPI Python Microservices

Asynchronous Processing

  • Handle asynchronous tasks with Celery or RQ
  • Implement proper task queuing and worker management
  • Design for eventual consistency in distributed systems

Observability

  • Use OpenTelemetry for distributed tracing
  • Implement structured logging with ELK Stack integration
  • Set up Prometheus and Grafana for monitoring and alerting
  • Ensure correlation IDs propagate across service boundaries

Security

  • Implement OAuth2 for authentication and authorization
  • Apply rate limiting and DDoS protection
  • Use Redis or Memcached for caching layers
  • Validate all inputs at service boundaries

Go Backend Development for Microservices

Architecture

  • Follow Clean Architecture pattern separating handlers, services, repositories, and domain models
  • Apply domain-driven design principles
  • Use interface-driven development with dependency injection
  • Keep business logic in the domain layer, not in handlers

Project Structure

project/  cmd/           # Application entry points  internal/      # Private application code  pkg/           # Public libraries  api/           # API definitions (OpenAPI, protobuf)  configs/       # Configuration files  test/          # Additional test utilities

Error Handling

  • Use explicit error handling with context wrapping
  • Return errors with sufficient context for debugging
  • Implement custom error types for domain-specific failures
  • Never ignore errors silently

Concurrency

  • Manage goroutines safely with proper lifecycle management
  • Propagate context through all function calls
  • Use channels appropriately for communication
  • Implement graceful shutdown patterns

Testing

  • Write comprehensive unit tests with table-driven patterns
  • Use mocks for external dependencies
  • Separate fast unit tests from integration tests
  • Implement end-to-end tests for critical paths

Resilience

  • Implement retries with exponential backoff
  • Use circuit breakers to prevent cascade failures
  • Design for graceful degradation
  • Handle partial failures appropriately

来源与署名

来源:mindrally/skills位于microservices提交9718410

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架