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 從公開儲存庫中收錄這些內容。

檢舉或申請下架