Token导航 LogoToken导航TokenDH.com
研究检索external-servicegithub未标认证来源可访问许可证需确认审计通过

microservices-patterns微服务模式

Agent Skill

用于辅助文档、README、Markdown、说明文和内容稿件的整理与改写。它适合让 Agent 提炼结构、补齐章节、统一术语、检查链接或把零散材料整理成可读文档。使用时应保留项目已有事实、命令和路径,不要把未确认的信息写成确定结论;涉及对外文案时,还需要控制语气,避免过度营销或夸大能力。

总安装

194

周安装

8

GitHub Stars

11

下载量

63
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:microservices-patterns(微服务模式)
来源仓库:https://github.com/lobbi-docs/claude
仓库路径:skills/microservices-patterns
安装命令:
npx skills add https://github.com/lobbi-docs/claude --skill microservices-patterns
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/lobbi-docs/claude --skill microservices-patterns

简介

用于辅助文档、README、Markdown、说明文和内容稿件的整理与改写。

  • 适合提炼结构、补齐章节、统一术语或检查链接,提升内容可读性。
  • 使用时保留项目已有事实和命令,避免将未确认信息写成确定结论。
  • 涉及对外文案时需控制语气,防止过度营销或夸大能力。
  • 安装方式:通过 npx 从 GitHub 仓库添加技能。

SKILL.md

.NET Microservices Patterns

Service Decomposition

By Business Capability

E-Commerce Platform:
├── Catalog Service (products, categories, search)
├── Order Service (orders, order processing)
├── Payment Service (payment processing, refunds)
├── Inventory Service (stock management)
├── Notification Service (email, SMS, push)
├── Identity Service (authentication, users)
└── Gateway (API gateway, BFF)

Database Per Service

Each service owns its data store. No shared databases.

// Catalog uses PostgreSQL
builder.AddNpgsqlDbContext<CatalogDbContext>("catalogdb");

// Order uses SQL Server
builder.AddSqlServerDbContext<OrderDbContext>("orderdb");

// Notification uses Cosmos DB
builder.AddCosmosDbContext<NotificationDbContext>("cosmosdb");

Communication Patterns

Synchronous (HTTP/gRPC)

  • Use for queries that need immediate response
  • gRPC for internal service-to-service (performance)
  • REST for external APIs and BFF

Asynchronous (Messages/Events)

  • Use for commands that can be processed later
  • Event-driven for loose coupling between services
  • RabbitMQ or Azure Service Bus for message broker

CQRS Pattern

// Command side
public sealed record CreateOrderCommand(int CustomerId, List<OrderItemDto> Items);

public sealed class CreateOrderHandler(OrderDbContext db, IPublishEndpoint bus)
{
    public async Task<int> HandleAsync(CreateOrderCommand command, CancellationToken ct)
    {
        var order = Order.Create(command.CustomerId, command.Items);
        db.Orders.Add(order);
        await db.SaveChangesAsync(ct);

        await bus.Publish(new OrderCreatedEvent(order.Id, order.CustomerId), ct);
        return order.Id;
    }
}

// Query side (separate read model, possibly different DB)
public sealed class OrderQueryService(IReadOnlyDbContext readDb)
{
    public async Task<OrderDetailDto?> GetByIdAsync(int id, CancellationToken ct) =>
        await readDb.Orders
            .AsNoTracking()
            .Where(o => o.Id == id)
            .Select(o => o.ToDetailDto())
            .FirstOrDefaultAsync(ct);
}

Saga Pattern (Orchestration)

// Using MassTransit state machine
public sealed class OrderSaga : MassTransitStateMachine<OrderSagaState>
{
    public OrderSaga()
    {
        InstanceState(x => x.CurrentState);

        Event(() => OrderCreated, x => x.CorrelateById(m => m.Message.OrderId));
        Event(() => PaymentProcessed, x => x.CorrelateById(m => m.Message.OrderId));
        Event(() => InventoryReserved, x => x.CorrelateById(m => m.Message.OrderId));

        Initially(
            When(OrderCreated)
                .Then(ctx => ctx.Saga.OrderId = ctx.Message.OrderId)
                .Publish(ctx => new ProcessPaymentCommand(ctx.Saga.OrderId))
                .TransitionTo(AwaitingPayment));

        During(AwaitingPayment,
            When(PaymentProcessed)
                .Publish(ctx => new ReserveInventoryCommand(ctx.Saga.OrderId))
                .TransitionTo(AwaitingInventory),
            When(PaymentFailed)
                .Publish(ctx => new CancelOrderCommand(ctx.Saga.OrderId))
                .TransitionTo(Failed));

        During(AwaitingInventory,
            When(InventoryReserved)
                .Publish(ctx => new FulfillOrderCommand(ctx.Saga.OrderId))
                .TransitionTo(Completed));
    }
}

Resilience Patterns

// Microsoft.Extensions.Resilience + Polly v8
builder.Services.AddHttpClient<ICatalogClient>(client =>
    client.BaseAddress = new("https+http://catalog-api"))
.AddStandardResilienceHandler(); // Retry + Circuit Breaker + Timeout

// Custom pipeline
builder.Services.AddResiliencePipeline("custom", pipeline =>
{
    pipeline
        .AddRetry(new() { MaxRetryAttempts = 3, BackoffType = DelayBackoffType.Exponential })
        .AddCircuitBreaker(new() { FailureRatio = 0.5, MinimumThroughput = 10 })
        .AddTimeout(TimeSpan.FromSeconds(5));
});

Health Checks

builder.Services.AddHealthChecks()
    .AddNpgSql(connectionString, name: "database")
    .AddRedis(redisConnection, name: "cache")
    .AddRabbitMQ(rabbitConnection, name: "messaging")
    .AddCheck<CustomHealthCheck>("custom");

app.MapHealthChecks("/health/ready", new() { Predicate = check => check.Tags.Contains("ready") });
app.MapHealthChecks("/health/live", new() { Predicate = _ => false }); // Just checks app is running

API Gateway vs Direct Communication

PatternUse whenTrade-offs
Direct client-to-serviceFew services, internal appsSimple but couples clients to services
API Gateway (YARP/Ocelot)Many services, external clientsSingle entry point, adds latency
BFF (Backend for Frontend)Multiple client types (web, mobile)Client-optimized APIs, more gateways
// YARP reverse proxy (Microsoft's recommended API gateway)
builder.Services.AddReverseProxy()
    .LoadFromConfig(builder.Configuration.GetSection("ReverseProxy"));
app.MapReverseProxy();

Data Sovereignty Per Microservice

Each service owns its data. Cross-service data needs are resolved via:

  • API calls for real-time queries
  • Integration events for eventual consistency
  • Materialized views for read-heavy cross-service queries
Order Service ──(event)──> Catalog Service
  │ OrderDB                    │ CatalogDB
  │ (orders, items)            │ (products, stock)
  │                            │
  └──(HTTP)──> Payment Service
                  │ PaymentDB
                  │ (payments, refunds)

Asynchronous Message-Based Communication

// Integration events cross service boundaries
public abstract record IntegrationEvent
{
    public Guid Id { get; } = Guid.NewGuid();
    public DateTime CreatedAt { get; } = DateTime.UtcNow;
}

public sealed record OrderSubmittedIntegrationEvent(
    int OrderId, int BuyerId, decimal Total) : IntegrationEvent;

// Publish via outbox pattern for reliability
public sealed class OutboxPublisher(AppDbContext db, IEventBus bus)
{
    public async Task PublishPendingEventsAsync(CancellationToken ct)
    {
        var pending = await db.OutboxMessages
            .Where(m => !m.Published)
            .OrderBy(m => m.CreatedAt)
            .Take(50)
            .ToListAsync(ct);

        foreach (var message in pending)
        {
            await bus.PublishAsync(message.Event, ct);
            message.Published = true;
            message.PublishedAt = DateTime.UtcNow;
        }
        await db.SaveChangesAsync(ct);
    }
}

Composite UI (Micro-Frontends with Blazor)

Each service can own a UI fragment:

@* Main Blazor app composes service-specific components *@
<CatalogProductList />      @* Owned by Catalog team *@
<OrderStatusWidget />       @* Owned by Order team *@
<CartSummary />             @* Owned by Cart team *@

Pattern options:

  • Server-side composition: Aggregate HTML from multiple services
  • Client-side composition: Load Blazor components from different assemblies
  • API composition: BFF aggregates data, single Blazor app renders

Microservice Security

// JWT validation at API gateway
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
    .AddJwtBearer(options =>
    {
        options.Authority = "https://identity-service";
        options.Audience = "catalog-api";
    });

// Azure Key Vault for secrets
builder.Configuration.AddAzureKeyVault(
    new Uri("https://myvault.vault.azure.net/"),
    new DefaultAzureCredential());

Reference Documentation

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

34.37%
按下载量换算22

Claude

32.18%
按下载量换算20

Cursor

19.78%
按下载量换算12

Gemini CLI

9.79%
按下载量换算6

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

external-service

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills