* 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 )
| 234 | * Output: /_svc/{name}/crons/jobs/cleanup/sync_handler |
| 235 | */ |
| 236 | function 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 | } |
no test coverage detected