Documentation
¶
Index ¶
- Variables
- func RunFailedCandidate(org, project, environment, pipeline, run, root slug.Slug, at time.Time) model.NotificationCandidate
- func ValidateCandidate(params CreateCandidateParams) error
- type AlertDestinationTestJob
- type AlertDestinationTestResult
- type AlertManagementPrincipal
- type CandidateProducer
- type ConnectionProvider
- type ConnectionProviders
- type ContractFailureParams
- type CreateAlertDestinationParams
- type CreateAlertPolicyParams
- type CreateCandidateParams
- type CreateCandidateResult
- type DeliverNotificationParams
- type DeliveryError
- type LifecycleEventProducer
- type LifecycleEventProducerFunc
- type ListNotificationsFilters
- type MarkAlertDeliveryAttemptFailedParams
- type MarkAlertDeliveryAttemptSentParams
- type NotificationDeliveryJobParams
- type NotificationDeliveryProducer
- type NotificationEmailProducer
- type Service
- type TestAlertDestinationParams
- type UpdateAlertDestinationParams
- type UpdateAlertPolicyParams
- type UpsertRecordParams
Constants ¶
This section is empty.
Variables ¶
var ( ErrDestinationNotFound = reponotifications.ErrDestinationNotFound ErrDestinationSlugTaken = reponotifications.ErrDestinationSlugTaken ErrDestinationDisabled = xerror.New(xerror.KindInvalidInput, "ALERT_DESTINATION_DISABLED", "alert destination disabled") ErrDestinationTestUnsupported = xerror.New( xerror.KindUnsupported, "ALERT_DESTINATION_TEST_UNSUPPORTED", "alert destination test unsupported", ) ErrAlertPolicyNotFound = reponotifications.ErrAlertPolicyNotFound ErrAlertPolicySlugTaken = reponotifications.ErrAlertPolicySlugTaken ErrRecordNotFound = reponotifications.ErrRecordNotFound ErrRecordSlugTaken = reponotifications.ErrRecordSlugTaken ErrDeliveryNotFound = reponotifications.ErrDeliveryNotFound ErrInvalidInput = xerror.ValidationFailed() )
Functions ¶
func RunFailedCandidate ¶
func RunFailedCandidate(org, project, environment, pipeline, run, root slug.Slug, at time.Time) model.NotificationCandidate
RunFailedCandidate is called only after the source owner rules out automatic retry.
func ValidateCandidate ¶
func ValidateCandidate(params CreateCandidateParams) error
ValidateCandidate applies the same safe-evidence contract before queueing and persistence.
Types ¶
type AlertDestinationTestJob ¶
type AlertDestinationTestResult ¶
type AlertDestinationTestResult struct {
DestinationSlug slug.Slug
DestinationType model.AlertDestinationType
RecipientCount int
DiagnosticsPersisted bool
EnqueuedJobs []AlertDestinationTestJob
}
type AlertManagementPrincipal ¶
type AlertManagementPrincipal struct {
UserSlug slug.Slug
APIKeySlug slug.Slug
APIKeyOrgSlug slug.Slug
APIKeyRoleSlug slug.Slug
}
AlertManagementPrincipal identifies the authenticated actor for user-facing alert management.
func (AlertManagementPrincipal) EventActor ¶
func (p AlertManagementPrincipal) EventActor() model.EventActor
EventActor returns the durable-event actor represented by the alert management principal.
type CandidateProducer ¶
type CandidateProducer interface {
EnqueueCandidate(context.Context, postgres.DBTX, CreateCandidateParams) error
}
CandidateProducer durably hands any notification observation to the same candidate worker. It joins the source transaction; provider I/O stays downstream.
type ConnectionProvider ¶
ConnectionProvider sends through a managed notification connection, without exposing its credentials.
type ConnectionProviders ¶
type ConnectionProviders map[model.AlertDestinationType]ConnectionProvider
type ContractFailureParams ¶
type ContractFailureParams struct {
OrgSlug, ProjectSlug, EnvironmentSlug, PipelineSlug slug.Slug
RunSlug, ValidationSlug slug.Slug
StepSlug slug.Slug
CheckID, ContractName, ContractRevision, Field, Rule string
ReasonCode string
ObservedAt time.Time
}
ContractFailureParams identifies a durable enforced failure. Producers pass declaration identities and fixed diagnostic codes, never evaluated values.
type CreateAlertPolicyParams ¶
type CreateAlertPolicyParams struct {
OrgSlug slug.Slug `validate:"required"`
Slug slug.Slug
Name string `validate:"required"`
Scope model.AlertPolicyScope `validate:"alertpolicyscope"`
ProjectSlug *slug.Slug
EnvironmentSlug *slug.Slug
// NotificationType and Severity are optional individually; policy validation requires at least one.
NotificationType *model.NotificationType `validate:"omitempty,notificationtype"`
Severity *model.NotificationSeverity `validate:"omitempty,notificationseverity"`
LifecycleState *model.NotificationLifecycleState `validate:"omitempty,notificationlifecyclestate"`
SourceKind *model.EventEntityType `validate:"omitempty,evententitytype"`
SourceAction *model.EventAction `validate:"omitempty,eventaction"`
SourceRef *slug.Slug
DestinationSlugs []slug.Slug
}
type CreateCandidateParams ¶
type CreateCandidateParams = model.NotificationCandidate
func ContractFailureCandidate ¶
func ContractFailureCandidate(p ContractFailureParams) (CreateCandidateParams, error)
type CreateCandidateResult ¶
type CreateCandidateResult struct {
Record *model.NotificationRecord
}
type DeliveryError ¶
type DeliveryError struct {
Category string
Message string
Retryable bool
RetryAfter time.Duration
}
DeliveryError contains only safe diagnostics and the provider's retry instruction.
func (*DeliveryError) Error ¶
func (e *DeliveryError) Error() string
type LifecycleEventProducer ¶
type LifecycleEventProducer interface {
EnqueueRecord(
ctx context.Context,
tx postgres.DBTX,
orgSlug slug.Slug,
actor model.EventActor,
event eventrecorder.Event,
)
EnqueueRequired(
ctx context.Context,
tx postgres.DBTX,
orgSlug slug.Slug,
actor model.EventActor,
event eventrecorder.Event,
) error
}
LifecycleEventProducer avoids an import cycle with service/worker/producer: notificationsvc needs only this enqueue capability, while worker producer already imports notificationsvc for notification delivery jobs. Broader package refactoring would be disproportionate for this narrow lifecycle-audit path.
type LifecycleEventProducerFunc ¶
type LifecycleEventProducerFunc func( ctx context.Context, tx postgres.DBTX, orgSlug slug.Slug, actor model.EventActor, event eventrecorder.Event, )
LifecycleEventProducerFunc adapts a function to LifecycleEventProducer.
func (LifecycleEventProducerFunc) EnqueueRecord ¶
func (f LifecycleEventProducerFunc) EnqueueRecord( ctx context.Context, tx postgres.DBTX, orgSlug slug.Slug, actor model.EventActor, event eventrecorder.Event, )
EnqueueRecord calls the wrapped producer function.
func (LifecycleEventProducerFunc) EnqueueRequired ¶
func (f LifecycleEventProducerFunc) EnqueueRequired( ctx context.Context, tx postgres.DBTX, orgSlug slug.Slug, actor model.EventActor, event eventrecorder.Event, ) error
EnqueueRequired preserves the legacy function adapter for call sites that intentionally cannot fail. Production adapters must provide their own fail-closed implementation.
type ListNotificationsFilters ¶
type ListNotificationsFilters struct {
LifecycleState *model.NotificationLifecycleState
NotificationType *model.NotificationType
Severity *model.NotificationSeverity
SourceKind *model.EventEntityType
SourceAction *model.EventAction
SourceRef *slug.Slug
IncludeResolved bool
}
type Service ¶
type Service interface {
CreateAlertDestination(
ctx context.Context,
principal AlertManagementPrincipal,
params CreateAlertDestinationParams,
) (*model.AlertDestination, error)
ListAlertDestinations(
ctx context.Context,
principal AlertManagementPrincipal,
orgSlug slug.Slug,
req model.ListRequest,
) (model.ListResponse[*model.AlertDestination], error)
GetAlertDestination(
ctx context.Context,
principal AlertManagementPrincipal,
orgSlug slug.Slug,
destinationSlug slug.Slug,
) (*model.AlertDestination, error)
TestAlertDestination(
ctx context.Context,
principal AlertManagementPrincipal,
params TestAlertDestinationParams,
) (*AlertDestinationTestResult, error)
UpdateAlertDestination(
ctx context.Context,
principal AlertManagementPrincipal,
params UpdateAlertDestinationParams,
) (*model.AlertDestination, error)
DeleteAlertDestination(
ctx context.Context,
principal AlertManagementPrincipal,
orgSlug slug.Slug,
destinationSlug slug.Slug,
) error
CreateAlertPolicy(ctx context.Context, principal AlertManagementPrincipal, params CreateAlertPolicyParams) (*model.AlertPolicy, error)
ListAlertPolicies(
ctx context.Context,
principal AlertManagementPrincipal,
orgSlug slug.Slug,
req model.ListRequest,
) (model.ListResponse[*model.AlertPolicy], error)
GetAlertPolicy(ctx context.Context, principal AlertManagementPrincipal, orgSlug, policySlug slug.Slug) (*model.AlertPolicy, error)
UpdateAlertPolicy(ctx context.Context, principal AlertManagementPrincipal, params UpdateAlertPolicyParams) (*model.AlertPolicy, error)
DeleteAlertPolicy(ctx context.Context, principal AlertManagementPrincipal, orgSlug, policySlug slug.Slug) error
CreateCandidate(ctx context.Context, params CreateCandidateParams) (*CreateCandidateResult, error)
UpsertRecord(ctx context.Context, params UpsertRecordParams) (*model.NotificationRecord, error)
ListNotifications(
ctx context.Context,
orgSlug slug.Slug,
filters ListNotificationsFilters,
req model.ListRequest,
) (model.ListResponse[*model.NotificationListItem], error)
GetNotification(
ctx context.Context,
orgSlug slug.Slug,
recordSlug slug.Slug,
) (*model.NotificationListItem, error)
AcknowledgeNotification(
ctx context.Context,
principal AlertManagementPrincipal,
orgSlug slug.Slug,
recordSlug slug.Slug,
) (*model.NotificationListItem, error)
ResolveNotification(
ctx context.Context,
principal AlertManagementPrincipal,
orgSlug slug.Slug,
recordSlug slug.Slug,
) (*model.NotificationListItem, error)
ListAlertDeliveryAttempts(
ctx context.Context,
orgSlug slug.Slug,
recordSlug slug.Slug,
req model.ListRequest,
) (model.ListResponse[*model.AlertDeliveryAttempt], error)
ListRecentAlertDeliveryAttemptsForRecords(
ctx context.Context,
orgSlug slug.Slug,
recordSlugs []slug.Slug,
limitPerRecord int,
) ([]*model.AlertDeliveryAttempt, error)
DeliverNotification(ctx context.Context, params DeliverNotificationParams) error
MarkAlertDeliveryAttemptSent(ctx context.Context, params MarkAlertDeliveryAttemptSentParams) error
MarkAlertDeliveryAttemptFailed(ctx context.Context, params MarkAlertDeliveryAttemptFailedParams) error
}
func New ¶
func New( txm postgres.TransactionManager, repo reponotifications.Repository, clk clock.Clock, deliveryProducer NotificationDeliveryProducer, emailProducer NotificationEmailProducer, eventProducer LifecycleEventProducer, connectionProviders ConnectionProviders, frontendURL string, ) Service
New creates a notification service with repository-backed persistence.
type UpdateAlertPolicyParams ¶
type UpdateAlertPolicyParams struct {
OrgSlug slug.Slug `validate:"required"`
Slug slug.Slug `validate:"required"`
Name string `validate:"required"`
Scope model.AlertPolicyScope `validate:"alertpolicyscope"`
ProjectSlug *slug.Slug
EnvironmentSlug *slug.Slug
// NotificationType and Severity are optional individually; policy validation requires at least one.
NotificationType *model.NotificationType `validate:"omitempty,notificationtype"`
Severity *model.NotificationSeverity `validate:"omitempty,notificationseverity"`
LifecycleState *model.NotificationLifecycleState `validate:"omitempty,notificationlifecyclestate"`
SourceKind *model.EventEntityType `validate:"omitempty,evententitytype"`
SourceAction *model.EventAction `validate:"omitempty,eventaction"`
SourceRef *slug.Slug
DestinationSlugs []slug.Slug
Enabled bool
}
type UpsertRecordParams ¶
type UpsertRecordParams struct {
OrgSlug slug.Slug `validate:"required"`
Slug slug.Slug `validate:"required"`
ProjectSlug *slug.Slug
EnvironmentSlug *slug.Slug
NotificationType model.NotificationType `validate:"notificationtype"`
Severity model.NotificationSeverity `validate:"notificationseverity"`
DedupeFingerprint string `validate:"required"`
SourceEventSlug *slug.Slug
SourceEntityType model.EventEntityType `validate:"evententitytype"`
SourceAction model.EventAction `validate:"eventaction"`
SourceRefs map[string]string
SafeMetadata map[string]any
}