MCPcopy Index your code
hub / github.com/simstudioai/sim / pollProvider

Function pollProvider

apps/sim/lib/webhooks/polling/orchestrator.ts:8–46  ·  view source on GitHub ↗
(providerName: string)

Source from the content-addressed store, hash-verified

6
7/** Poll all active webhooks for a given provider. */
8export async function pollProvider(providerName: string): Promise<PollSummary> {
9 const handler = getPollingHandler(providerName)
10 if (!handler) {
11 throw new Error(`Unknown polling provider: ${providerName}`)
12 }
13
14 const logger = createLogger(`${handler.label}PollingService`)
15 logger.info(`Starting ${handler.label} webhook polling`)
16
17 const activeWebhooks = await fetchActiveWebhooks(handler.provider)
18 if (!activeWebhooks.length) {
19 logger.info(`No active ${handler.label} webhooks found`)
20 return { total: 0, successful: 0, failed: 0 }
21 }
22
23 logger.info(`Found ${activeWebhooks.length} active ${handler.label} webhooks`)
24
25 const { successCount, failureCount } = await runWithConcurrency(
26 activeWebhooks,
27 async (entry) => {
28 const requestId = generateShortId()
29 return handler.pollWebhook({
30 webhookData: entry.webhook,
31 workflowData: entry.workflow,
32 requestId,
33 logger,
34 })
35 },
36 logger
37 )
38
39 const summary: PollSummary = {
40 total: activeWebhooks.length,
41 successful: successCount,
42 failed: failureCount,
43 }
44 logger.info(`${handler.label} polling completed`, summary)
45 return summary
46}

Callers 1

route.tsFile · 0.90

Calls 7

getPollingHandlerFunction · 0.90
createLoggerFunction · 0.90
fetchActiveWebhooksFunction · 0.90
runWithConcurrencyFunction · 0.90
generateShortIdFunction · 0.90
infoMethod · 0.80
pollWebhookMethod · 0.80

Tested by

no test coverage detected