distributed-events-advanced
БесплатноБез исполняемых скриптовНе проверенAdvanced distributed event patterns for ABP microservices including idempotent handlers, cross-tenant events, event sourcing lite, and saga patterns. Use…
Об этом скилле
Distributed Events Advanced Patterns
Master advanced distributed event patterns for building resilient, scalable ABP microservices architectures.
When to Use This Skill
- Implementing event handlers that process events from other microservices
- Building idempotent event processing to handle duplicates
- Cross-tenant event synchronization
- Designing event-driven communication patterns
- Implementing saga/choreography patterns
- Troubleshooting event delivery issues
Core Concepts
Event Transfer Objects (ETOs)
ETOs are the payload of distributed events. Define them in a shared library accessible by both publisher and subscriber.
// Shared/Etos/PatientCreatedEto.cs
[EventName("patient.created")] // Optional: explicit event name
public class PatientCreatedEto
{
public Guid Id { get; set; }
public Guid? TenantId { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public DateTime CreatedAt { get; set; }
// Include correlation ID for tracing
public string CorrelationId { get; set; }
}
ETO Best Practices:
- Include
TenantIdfor multi-tenant scenarios - Include
CorrelationIdfor distributed tracing - Use primitive types only (no navigation properties)
- Version ETOs carefully (add properties, don't remove)
Event Handler Patterns
1. Basic Event Handler
public class PatientCreatedEventHandler :
IDistributedEventHandler<PatientCreatedEto>,
ITransientDependency
{
private readonly ILogger<PatientCreatedEventHandler> _logger;
public PatientCreatedEventHandler(
ILogger<PatientCreatedEventHandler> logger)
{
_logger = logger;
}
public async Task HandleEventAsync(PatientCreatedEto eventData)
{
_logger.LogInformation(
"Processing PatientCreated event: {PatientId}",
eventData.Id);
// Handle the event
await ProcessPatientAsync(eventData);
}
}
2. Idempotent Event Handler
Handle duplicate events gracefully using idempotency keys.
public class PatientSyncEventHandler :
IDistributedEventHandler<PatientCreatedEto>,
ITransientDependency
{
private readonly IRepository<Patient, Guid> _repository;
private readonly IRepository<ProcessedEvent, Guid> _processedEventRepository;
private readonly ILogger<PatientSyncEventHandler> _logger;
public async Task HandleEventAsync(PatientCreatedEto eto)
{
// Idempotency check using event ID or correlation ID
var eventKey = $"PatientCreated:{eto.Id}";
if (await _processedEventRepository.AnyAsync(x => x.EventKey == eventKey))
{
_logger.LogInformation(
"Event already processed, skipping: {EventKey}", eventKey);
return;
}
try
{
// Check if entity already exists
var existing = await _repository.FirstOrDefaultAsync(
x => x.ExternalId == eto.Id);
if (existing != null)
{
_logger.LogInformation(
"Patient already exists, updating: {PatientId}", eto.Id);
existing.SetName(eto.Name);
await _repository.UpdateAsync(existing);
}
else
{
var patient = new Patient(
GuidGenerator.Create(),
eto.Name,
eto.Email)
{
ExternalId = eto.Id
};
await _repository.InsertAsync(patient);
}
// Record processed event
await _processedEventRepository.InsertAsync(new ProcessedEvent
{
EventKey = eventKey,
ProcessedAt = DateTime.UtcNow
});
_logger.LogInformation(
"Successfully processed PatientCreated: {PatientId}", eto.Id);
}
catch (Exception ex)
{
_logger.LogError(ex,
"Failed to process PatientCreated: {PatientId}", eto.Id);
throw; // Re-throw to trigger retry
}
}
}
// Entity for tracking processed events
public class ProcessedEvent : Entity<Guid>
{
public string EventKey { get; set; }
public DateTime ProcessedAt { get; set; }
}
3. Cross-Tenant Event Handler
Handle events that need to operate across tenant boundaries.
public class EntitySyncEventHandler :
IDistributedEventHandler<EntityUpdatedEto>,
ITransientDependency
{
private readonly IRepository<Entity, Guid> _repository;
private readonly IDataFilter _dataFilter;
private readonly ICurrentTenant _currentTenant;
private readonly ILogger<EntitySyncEventHandler> _logger;
public async Task HandleEventAsync(EntityUpdatedEto eto)
{
_logger.LogInformation(
"Processing cross-tenant sync: {EntityId}, TargetTenant: {TenantId}",
eto.Id, e
Установить distributed-events-advanced в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл distributed-events-advanced?
Advanced distributed event patterns for ABP microservices including idempotent handlers, cross-tenant events, event sourcing lite, and saga patterns. Use when: (1) implementing event handlers across services, (2) ensuring idempotent event processing, (3) cross-tenant event handling, (4) designing event-driven architectures.
Как установить скилл distributed-events-advanced?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл distributed-events-advanced запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic