Results Handler Flow
This flowchart shows the initialization and execution flow of the results service.
Architecture Overview
event-pers.push.results.{mode}.{group}")] %% Main Handler subgraph "Results Handler" RH[Results Handler] Pipeline[Processing Pipeline] subgraph "Pipeline Steps" ParseStep[Parse Message Step] CheckAbortStep[Check Abort Personalization Step] ChannelStep[Determine Channel Step] FetchTemplateStep[Fetch Results Template Step] FailuresStep[Process Failures Step] ValidateStep[Validate Results Step] ProcessResultsStep[Process Results With Template Step] end end %% Channel System subgraph "Channel System" Registry[Channel Registry] PushChannel[Push Channel
with Results Processing] end %% Publishers & Services subgraph "Publishers & Services" DeviceMapper["Device Mapper Publisher
sending_mode_devicemapper_group"] ErrorsPublisher["Errors Publisher
config.ErrorsTopic"] subgraph "Event Publishers" MobileEvents[Mobile Event Publisher
Main PubSub Client] DPEvents[DP Event Publisher
DP PubSub Client] end end %% External Dependencies subgraph "External Services" PushCampaignService[(Push Campaign Service)] DownstreamServices[(Downstream Services)] end %% PubSub Clients subgraph "PubSub Clients" MainClient[Main PubSub Client
GCloudProjectId] DPClient[DP PubSub Client
DPGCloudProjectId] PersClient[Personalization Client
PersGCloudProjectId] end %% Flow connections PubSub --> RH RH --> Pipeline Pipeline --> ParseStep ParseStep --> CheckAbortStep CheckAbortStep --> ChannelStep ChannelStep --> FetchTemplateStep FetchTemplateStep --> FailuresStep FailuresStep --> ValidateStep ValidateStep --> ProcessResultsStep %% Channel processing ChannelStep --> Registry Registry --> PushChannel %% Success path ProcessResultsStep --> PushChannel PushChannel --> PushCampaignService PushChannel --> MobileEvents PushChannel --> DPEvents MobileEvents --> DownstreamServices DPEvents --> DownstreamServices %% Failure path FailuresStep --> DeviceMapper %% Error handling FailuresStep --> ErrorsPublisher ProcessResultsStep --> ErrorsPublisher %% Client connections RH --> PersClient DeviceMapper --> MainClient ErrorsPublisher --> MainClient MobileEvents --> MainClient DPEvents --> DPClient PushChannel --> MainClient PushChannel --> PersClient %% Styling classDef handler fill:#fce4ec,stroke:#c2185b,stroke-width:2px classDef pipeline fill:#e3f2fd,stroke:#1976d2,stroke-width:2px classDef channel fill:#e1f5fe,stroke:#01579b,stroke-width:2px classDef publisher fill:#f3e5f5,stroke:#4a148c,stroke-width:2px classDef service fill:#e8f5e8,stroke:#2e7d32,stroke-width:2px classDef topic fill:#fff3e0,stroke:#ef6c00,stroke-width:2px classDef client fill:#fafafa,stroke:#424242,stroke-width:2px class RH,Pipeline handler class ParseStep,CheckAbortStep,ChannelStep,FetchTemplateStep,FailuresStep,ValidateStep,ProcessResultsStep pipeline class Registry,PushChannel channel class DeviceMapper,ErrorsPublisher,MobileEvents,DPEvents publisher class PushCampaignService,DownstreamServices service class PubSub topic class MainClient,DPClient,PersClient client
Processing Pipeline
JSON decode to PersonalizationResults Pipeline->>Pipeline: 2. Check Abort Personalization Step
Check if campaign/customer is cancelled Pipeline->>Registry: 3. Determine Channel Step
Get channel from message attributes Registry->>PC: Return push channel Pipeline->>PC: 4. Fetch Results Template Step
Get campaign metadata for result processing PC->>CampaignSvc: Fetch campaign data CampaignSvc->>PC: Campaign metadata alt Has Failures Pipeline->>PC: 5. Process Failures Step PC->>DeviceMapper: Send failures to device mapper DeviceMapper->>PS: Publish to devicemapper topic end Pipeline->>Pipeline: 6. Validate Results Step
Check if results are valid alt Has Successful Results Pipeline->>PC: 7. Process Results With Template Step loop For each result PC->>PC: Build downstream message with template PC->>EventPub: Publish to event publishers EventPub->>Downstream: Send to mobile/DP services end end alt Processing Errors Pipeline->>RH: Handle pipeline errors RH->>PS: Publish to errors topic end RH->>PS: Acknowledge message
Channel-Specific Methods Usage
(Push/EmbeddedMessaging) participant CampaignSvc as Campaign Service participant EventPub as Event Publishers participant DeviceMapper as Device Mapper participant Downstream as Downstream Services Note over Handler: Received personalization results Handler->>Registry: DetermineChannel(message attributes) Registry->>Channel: Return channel instance rect rgb(230, 240, 255) Note over Handler,CampaignSvc: 1. GetCampaign - Fetch campaign for result processing Handler->>Channel: GetCampaign(customerId, campaignId) Channel->>CampaignSvc: Fetch campaign metadata CampaignSvc-->>Channel: Campaign data (template for results) Channel-->>Handler: Campaign metadata end alt Has Failures in Results rect rgb(255, 240, 240) Note over Handler,DeviceMapper: 2. ProcessFailures - Handle failed personalizations Handler->>Channel: ProcessFailures(failures, campaign) Channel->>DeviceMapper: Republish failures for retry Note over DeviceMapper: Failures sent back to retry queue end end alt Has Successful Results rect rgb(240, 255, 240) Note over Handler,Downstream: 3. ProcessResults - Handle successful personalizations Handler->>Channel: ProcessResults(results, campaign) loop For each successful result Channel->>Channel: BuildDownstreamMessage(result, campaign) Note over Channel: Creates message with
personalized content Channel->>EventPub: Publish to mobile/DP event streams EventPub->>Downstream: Forward to downstream services end end end Note over Handler: All results processed and published
Key Components
Pipeline Processing Steps
-
Parse Message Step: JSON deserialization of personalization results from PubSub message
-
Check Abort Personalization Step: Verify campaign/customer is not in cancellation list, abort if cancelled
-
Determine Channel Step: Route to appropriate channel handler (push, embedded_messaging)
-
Fetch Results Template Step: Retrieve campaign metadata needed for result processing
-
Process Failures Step: Handle failed personalization attempts, publish to device mapper for retry
-
Validate Results Step: Check if results data is valid, complete, and not on cloud storage
-
Process Results With Template Step: Build downstream messages using template and publish to event streams
External Dependencies
-
Multiple PubSub Clients: Main, DP, and Personalization project clients (all use cloud.google.com/go/pubsub/v2)
-
Event Publishers: Mobile and DP event publishing for downstream services
-
Device Mapper: Republishes failed personalization attempts for retry
-
Campaign Service: Fetches campaign metadata for result processing
Message Flow Paths
-
Success Path: Results → Campaign Service → Event Publishers → Downstream Services
-
Failure Path: Results → Device Mapper Publisher → Retry Queue
-
Error Path: Invalid/malformed messages → Errors Publisher
Configuration
-
Input Topic:
event-pers.push.results.{mode}.{group}(receives from personalization service) -
Subscription:
event-pers.push.results.{mode}.{group} -
Device Mapper Topic:
sending-{mode}-devicemapper-{group} -
Embedded Messaging Topic:
sending-{mode}-em-{group} -
Channels: Push and embedded_messaging channels with results processing capabilities
Processing Features
-
Pipeline Architecture: Sequential step processing with error handling
-
Channel-based Routing: Registry pattern for extensible channel support (push, embedded_messaging)
-
Abort Cancellation: Checks cancelled campaigns/customers early to prevent unnecessary processing
-
Failure Republishing: Failed personalization attempts sent back to device mapper for retry
-
Event Publishing: Dual mobile/DP event streams for different downstream consumers
-
Template-based Processing: Campaign metadata fetched once and reused for all results in batch