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
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
  • Blog
  • Pricing
  • Documentation
Yandex project
© 2025 Yandex.Cloud LLC
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

In this article:

  • Distinct data types
  • Handler requirements
  1. Developing in Kotlin
  2. Programming model
  3. Overview

Kotlin programming model

Written by
Yandex Cloud
Updated at August 22, 2024
  • Distinct data types
  • Handler requirements

Cloud Functions offers two Kotlin programming models: one is based on top-level functions, the other, on the YcFunction interface. Unlike top-level functions, the YcFunction interface enables you to access the invocation context.

Both programming models enable using Yandex Cloud services via the SDK. To do this, add the SDK to the Gradle dependencies.

Distinct data typesDistinct data types

Kotlin programming models feature various distinct data types, such as InputStream, String, and ByteArray. Using them is different from using other types. If the handler function argument is of a distinct type, the runtime environment does not convert an incoming HTTPS request to a JSON interpretation. Instead, it sends the request directly to the user handler.

Handling distinct types is different when they become Nullable. Let's assume the request body is null and the user invoked the function with the ?integration=raw parameter. The result the handler gets depends on the argument type:

  • If the argument is String?, the handler gets the null value.
  • If the argument is String, the handler gets a string containing the null text.

Note

The Moshi library is used for JSON serialization and deserialization.

Handler requirementsHandler requirements

Regardless of the selected model, a project is uploaded as a source code, a JAR archive, or a Gradle project. In addition, handler classes must meet specific requirements that differ depending on the programming model:

  • For top-level functions:

    • The function must be public.
    • It must not be generic.
  • For the YcFunction interface:

    • The class that contains a handler function must be public.

    • The class must have a public no-argument constructor.

      It is included by default. However, if you created your own constructor that accepts arguments, you must also create a no-argument one.

    • The class must not be generic.

Was the article helpful?

Previous
Overview
Next
Top-level function
Yandex project
© 2025 Yandex.Cloud LLC