Files
galaxy-game/backend/internal/notification/lobby_adapter.go
T
2026-05-06 10:14:55 +03:00

36 lines
923 B
Go

package notification
import (
"context"
"galaxy/backend/internal/lobby"
)
// LobbyAdapter returns an implementation of `lobby.NotificationPublisher`
// backed by *Service. The adapter copies the producer-side intent shape
// into notification.Intent and calls Submit; Submit's own malformed
// fallback handles invalid payloads, so the adapter never blocks the
// caller. The interface is the same one The wiring connects through the
// no-op publisher.
func (s *Service) LobbyAdapter() lobby.NotificationPublisher {
return &lobbyAdapter{svc: s}
}
type lobbyAdapter struct {
svc *Service
}
func (a *lobbyAdapter) PublishLobbyEvent(ctx context.Context, ev lobby.LobbyNotification) error {
if a == nil || a.svc == nil {
return nil
}
intent := Intent{
Kind: ev.Kind,
IdempotencyKey: ev.IdempotencyKey,
Recipients: ev.Recipients,
Payload: ev.Payload,
}
_, err := a.svc.Submit(ctx, intent)
return err
}