Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Yandex Cloud Functions
  • Comparison with other Yandex Cloud services
    • Overview
      • Overview
      • Top-level function
      • YcFunction interface
    • Managing dependencies
    • Request handler
    • Invocation context
    • Logging
    • Handling errors
    • Using the SDK
  • Tools
  • Pricing policy
  • Access management
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes
  • FAQ
  1. Developing in Kotlin
  2. Programming model
  3. YcFunction interface

Using the YcFunction interface for a handler in Kotlin

Written by
Yandex Cloud
Updated at August 22, 2024

To create a handler in Kotlin, you can implement the YcFunction interface. To do this, add the SDK to the dependencies.

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.

Was the article helpful?

Previous
Top-level function
Next
Managing dependencies
© 2025 Direct Cursus Technology L.L.C.