MCPcopy Create free account
hub / github.com/vercel/vercel / moduleColonFuncToCronPath

Function moduleColonFuncToCronPath

packages/python/src/crons.ts:236–252  ·  view source on GitHub ↗

* Convert a module:function string into a cron path. * * Input: "jobs.cleanup:sync_handler" * Output: /_svc/{name}/crons/jobs/cleanup/sync_handler

(
  serviceName: string,
  moduleFunction: string
)

Source from the content-addressed store, hash-verified

234 * Output: /_svc/{name}/crons/jobs/cleanup/sync_handler
235 */
236function moduleColonFuncToCronPath(
237 serviceName: string,
238 moduleFunction: string
239): string {
240 const colonIdx = moduleFunction.indexOf(':');
241 if (colonIdx === -1) {
242 throw new NowBuildError({
243 code: 'PYTHON_DYNAMIC_CRON_INVALID_FORMAT',
244 message: `Dynamic cron entry must use "module:function" format, got: "${moduleFunction}"`,
245 });
246 }
247 const modulePart = moduleFunction.slice(0, colonIdx);
248 const funcPart = moduleFunction.slice(colonIdx + 1);
249 // Convert dotted module path to slash-separated path
250 const entrypointPath = modulePart.replace(/\./g, '/');
251 return getInternalServiceCronPath(serviceName, entrypointPath, funcPart);
252}

Callers 1

getServiceCronsDynamicFunction · 0.85

Calls 2

replaceMethod · 0.80

Tested by

no test coverage detected