@@ -29,6 +29,7 @@ const (
2929 entityAuctionRequest entity = "auction-request"
3030 entityAuctionResponse entity = "auction_response"
3131 entityAllProcessedBidResponses entity = "all_processed_bid_responses"
32+ entityExitpoint entity = "exitpoint"
3233)
3334
3435type StageExecutor interface {
@@ -39,6 +40,7 @@ type StageExecutor interface {
3940 ExecuteRawBidderResponseStage (response * adapters.BidderResponse , bidder string ) * RejectError
4041 ExecuteAllProcessedBidResponsesStage (adapterBids map [openrtb_ext.BidderName ]* entities.PbsOrtbSeatBid )
4142 ExecuteAuctionResponseStage (response * openrtb2.BidResponse )
43+ ExecuteExitpointStage (response any , w http.ResponseWriter ) any
4244}
4345
4446type HookStageExecutor interface {
@@ -295,6 +297,35 @@ func (e *hookExecutor) ExecuteAuctionResponseStage(response *openrtb2.BidRespons
295297 e .pushStageOutcome (outcome )
296298}
297299
300+ func (e * hookExecutor ) ExecuteExitpointStage (response any , w http.ResponseWriter ) any {
301+ plan := e .planBuilder .PlanForExitpointStage (e .endpoint , e .account )
302+ if len (plan ) == 0 {
303+ return response
304+ }
305+
306+ handler := func (
307+ ctx context.Context ,
308+ moduleCtx hookstage.ModuleInvocationContext ,
309+ hook hookstage.Exitpoint ,
310+ payload hookstage.ExitpointPaylaod ,
311+ ) (hookstage.HookResult [hookstage.ExitpointPaylaod ], error ) {
312+ return hook .HandleExitpointHook (ctx , moduleCtx , payload )
313+ }
314+
315+ stageName := hooks .StageExitpoint .String ()
316+ executionCtx := e .newContext (stageName )
317+ payload := hookstage.ExitpointPaylaod {W : w , Response : response }
318+
319+ outcome , payload , context , _ := executeStage (executionCtx , plan , payload , handler , e .metricEngine )
320+ outcome .Entity = entityExitpoint
321+ outcome .Stage = stageName
322+
323+ e .saveModuleContexts (context )
324+ e .pushStageOutcome (outcome )
325+
326+ return payload .Response
327+ }
328+
298329func (e * hookExecutor ) newContext (stage string ) executionContext {
299330 return executionContext {
300331 account : e .account ,
@@ -353,4 +384,9 @@ func (executor EmptyHookExecutor) ExecuteRawBidderResponseStage(_ *adapters.Bidd
353384func (executor EmptyHookExecutor ) ExecuteAllProcessedBidResponsesStage (_ map [openrtb_ext.BidderName ]* entities.PbsOrtbSeatBid ) {
354385}
355386
356- func (executor EmptyHookExecutor ) ExecuteAuctionResponseStage (_ * openrtb2.BidResponse ) {}
387+ func (executor EmptyHookExecutor ) ExecuteAuctionResponseStage (_ * openrtb2.BidResponse ) {
388+ }
389+
390+ func (executor EmptyHookExecutor ) ExecuteExitpointStage (response any , _ http.ResponseWriter ) any {
391+ return response
392+ }
0 commit comments