feat: backend service
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package notification
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"galaxy/backend/internal/runtime"
|
||||
)
|
||||
|
||||
// RuntimeAdapter returns an implementation of
|
||||
// `runtime.NotificationPublisher` backed by *Service. The adapter
|
||||
// translates runtime's narrow `(kind, idempotency_key, payload)` shape
|
||||
// into a notification.Intent and calls Submit. Recipient resolution is
|
||||
// handled by Submit's catalog lookup: every kind runtime emits is
|
||||
// `Admin: true`, so the recipient comes from the configured
|
||||
// `BACKEND_NOTIFICATION_ADMIN_EMAIL`.
|
||||
func (s *Service) RuntimeAdapter() runtime.NotificationPublisher {
|
||||
return &runtimeAdapter{svc: s}
|
||||
}
|
||||
|
||||
type runtimeAdapter struct {
|
||||
svc *Service
|
||||
}
|
||||
|
||||
func (a *runtimeAdapter) PublishRuntimeEvent(ctx context.Context, kind, idempotencyKey string, payload map[string]any) error {
|
||||
if a == nil || a.svc == nil {
|
||||
return nil
|
||||
}
|
||||
intent := Intent{
|
||||
Kind: kind,
|
||||
IdempotencyKey: idempotencyKey,
|
||||
Payload: payload,
|
||||
}
|
||||
_, err := a.svc.Submit(ctx, intent)
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user