Skip to content

Conversation

@jcscottiii
Copy link
Collaborator

Updates the email worker's sender logic to handle delivery robustly and extends event types to propagate necessary context (ChannelID and Event IDs).

Changes:

  • Event Types: Added ChannelID to EmailJobEvent to ensure the consumer can identify the target channel.
  • Worker Types: Introduced IncomingEmailDeliveryJob to capture the EmailEventID (Pub/Sub message ID) for audit logging. Added sentinel errors (ErrUnrecoverableUserFailureEmailSending, ErrUnrecoverableSystemFailureEmailSending) to distinguish failure modes.
  • Sender Logic: Refactored ProcessMessage to:
    • Use IncomingEmailDeliveryJob for better context.
    • Handle distinct error types: Permanent user errors are recorded and ACKed; transient errors trigger NACKs for retry.
    • Pass EmailEventID and error classification to the ChannelStateManager for precise attempt tracking.
  • Pub/Sub Adapter: Added logging to PublishEmailJob to trace published IDs.

Updates the email worker's sender logic to handle delivery robustly and extends
event types to propagate necessary context (ChannelID and Event IDs).

Changes:
- **Event Types**: Added `ChannelID` to `EmailJobEvent` to ensure the consumer
  can identify the target channel.
- **Worker Types**: Introduced `IncomingEmailDeliveryJob` to capture the
  `EmailEventID` (Pub/Sub message ID) for audit logging. Added sentinel errors
  (`ErrUnrecoverableUserFailureEmailSending`, `ErrUnrecoverableSystemFailureEmailSending`)
  to distinguish failure modes.
- **Sender Logic**: Refactored `ProcessMessage` to:
  - Use `IncomingEmailDeliveryJob` for better context.
  - Handle distinct error types: Permanent user errors are recorded and ACKed;
    transient errors trigger NACKs for retry.
  - Pass `EmailEventID` and error classification to the `ChannelStateManager`
    for precise attempt tracking.
- **Pub/Sub Adapter**: Added logging to `PublishEmailJob` to trace published IDs.
@jcscottiii jcscottiii force-pushed the jcscottiii/email-worker-pt3 branch from b9da33d to f9040df Compare December 29, 2025 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant