override fun process()

in dsl/kotless/kotless-lang-parser/src/main/kotlin/io/kotless/parser/processor/events/ScheduledEventsProcessor.kt [25:45]


    override fun process(files: Set<KtFile>, binding: BindingContext, context: ProcessorContext) {
        val permissions = context.output.get(GlobalActionsProcessor).permissions
        val entrypoint = context.output.get(EntrypointProcessor).entrypoint

        processStaticFunctions(files, binding) { func, entry, _ ->
            require(func, func.fqName != null) { "@Scheduled cannot be applied to anonymous function" }
            require(func, func.valueParameters.isEmpty()) { "@Scheduled cannot be applied to ${func.fqName!!.asString()} since it has parameters" }

            val routePermissions = PermissionsProcessor.process(func, binding, context) + permissions

            val id = (entry.getValue(binding, Scheduled::id) ?: "").ifBlank { func.fqName!!.asString().hashCode().absoluteValue.toString() }

            val key = TypedStorage.Key<Lambda>()
            val function = Lambda(id, context.jar, entrypoint, context.lambda, routePermissions)

            val cron = entry.getValue(binding, Scheduled::cron) ?: error(func, "@Scheduled annotation must have `cron` parameter set")

            context.resources.register(key, function)
            context.events.register(Events.Scheduled(id, cron, ScheduledEventType.General, key))
        }
    }