package memory

import (
	"context"

	"github.com/rwadurian/mpc-system/pkg/logger"
	"github.com/rwadurian/mpc-system/services/account/application/ports"
	"go.uber.org/zap"
)

// EventPublisherAdapter implements EventPublisher using in-memory logging
// Events are logged but not distributed (suitable for single-instance deployment)
type EventPublisherAdapter struct{}

// NewEventPublisherAdapter creates a new in-memory event publisher
func NewEventPublisherAdapter() ports.EventPublisher {
	return &EventPublisherAdapter{}
}

// Publish logs the event (no actual distribution in single-instance mode)
func (p *EventPublisherAdapter) Publish(ctx context.Context, event ports.AccountEvent) error {
	logger.Info("Account event published",
		zap.String("type", string(event.Type)),
		zap.String("account_id", event.AccountID))
	return nil
}

// Close is a no-op for in-memory publisher
func (p *EventPublisherAdapter) Close() error {
	return nil
}

// Ensure interface compliance
var _ ports.EventPublisher = (*EventPublisherAdapter)(nil)
