Using the YcFunction interface for a handler in Kotlin
Written by
Updated at August 22, 2024
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 both values for YcFunction
type parameters: the first one is for the input argument type, while the second one, for 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 may have any access modifiers