mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 21:11:22 -05:00
feat: Implement retry logic and tracking
This commit is contained in:
@@ -2,6 +2,7 @@ import { serve } from "https://deno.land/std@0.168.0/http/server.ts";
|
||||
import { createClient } from "https://esm.sh/@supabase/supabase-js@2.57.4";
|
||||
import { Novu } from "npm:@novu/api@1.6.0";
|
||||
import { edgeLogger, startRequest, endRequest } from '../_shared/logger.ts';
|
||||
import { withEdgeRetry } from '../_shared/retryHelper.ts';
|
||||
|
||||
const corsHeaders = {
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
@@ -86,9 +87,17 @@ serve(async (req) => {
|
||||
const batch = uniqueUserIds.slice(i, i + batchSize);
|
||||
|
||||
try {
|
||||
await novu.topics.addSubscribers(topicKey, {
|
||||
subscribers: batch,
|
||||
});
|
||||
await withEdgeRetry(
|
||||
async () => {
|
||||
await novu.topics.addSubscribers(topicKey, {
|
||||
subscribers: batch,
|
||||
});
|
||||
},
|
||||
{ maxAttempts: 3, baseDelay: 2000 },
|
||||
tracking.requestId,
|
||||
`sync-batch-${topicKey}-${i}`
|
||||
);
|
||||
|
||||
successCount += batch.length;
|
||||
edgeLogger.info('Added batch of users to topic', {
|
||||
requestId: tracking.requestId,
|
||||
|
||||
Reference in New Issue
Block a user