Maps internal domain events to external integration events for cross-service communication in a microservices architecture.
// Source: https://github.com/foxminchan/BookWorm | License: MIT | Copyright Nhan Nguyen (nguyenxuannhan407@gmail.com)
// Provided via justclaw.it.com; keep this notice with the code.
using BookWorm.Contracts;
using BookWorm.Rating.Domain.Events;
namespace BookWorm.Rating.Infrastructure.Services;
internal sealed class EventMapper : IEventMapper
{
public IntegrationEvent MapToIntegrationEvent(DomainEvent @event)
{
return @event switch
{
FeedbackCreatedEvent feedbackCreatedEvent => new FeedbackCreatedIntegrationEvent(
feedbackCreatedEvent.BookId,
feedbackCreatedEvent.Rating,
feedbackCreatedEvent.FeedbackId
),
FeedbackDeletedEvent feedbackDeletedEvent => new FeedbackDeletedIntegratio
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key