Using the YcFunction interface for a handler in Kotlin
Written by
Updated at July 2, 2026
To create a handler in Kotlin, you can implement the YcFunction
Here is an example of a handler:
import yandex.cloud.sdk.functions.YcFunction
import yandex.cloud.sdk.functions.Context
class Handler : YcFunction<Int, Int> {
override fun handle(event: Int, context: Context?): Int {
return event
}
}
Warning
Specify two values for YcFunction type parameters: the first one being the input argument type and the second one, the return value type. For the handle method, make sure to provide the invocation context as its second argument.
You can use any classes as input and return types. Fields of these classes can have any access modifiers