Skip to content

inngest/inngest-kt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

116 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Inngest Kotlin SDK

Maven Central Version - inngest Maven Central Version - inngest-ktor-adapter Maven Central Version - inngest-spring-boot-adapter Discord

Inngest SDK for Kotlin with Java interoperability.

This SDK tracks the canonical Inngest SDK specification.

Defining a function

Kotlin
class TranscodeVideo : InngestFunction() {
  override fun config(builder: InngestFunctionConfigBuilder): InngestFunctionConfigBuilder =
    builder
      .id("process-video")
      .name("Process video upload")
      .triggerEvent("media/video.uploaded")
      .retries(2)
      .concurrency(10)

  override fun execute(
    ctx: FunctionContext,
    step: Step,
  ): HashMap<String, Any> {
    val transcription =
      step.run("transcribe-video") {
        // Download video, run through transcription model, return output
        "Hi there, My name is Jamie..." // dummy example content
      }

    val summary =
      step.run("summarize") {
        // Send t
        "Hi there, My name is Jamie..." // dummy example content
      }

    step.run("save-results") {
      // Save summary, to your database
      // database.save(event.data["videoId"], transcription, summary)
    }

    return hashMapOf("restored" to false)
  }
}
Java (Coming soon)

Creating functions

Define your function's configuration using the config method and the InngestFunctionConfigBuilder class. The config method must be overridden and an id is required. All options should are discoverable via the builder class passed as the only argument to the config method.

Kotlin
import java.time.Duration

class TranscodeVideo : InngestFunction() {
  override fun config(builder: InngestFunctionConfigBuilder): InngestFunctionConfigBuilder =
    builder
      .id("process-video")
      .name("Process video upload")
      .triggerEvent("media/video.uploaded")
      .retries(2)
      .batchEvents(50, Duration.ofSeconds(30))
      .concurrency(10)
}

Sending events (triggering functions)

Kotlin
import java.time.Duration

class TranscodeVideo : InngestFunction() {
  override fun config(builder: InngestFunctionConfigBuilder): InngestFunctionConfigBuilder =
    builder
      .id("process-video")
      .name("Process video upload")
      .triggerEvent("media/video.uploaded")
      .batchEvents(50, Duration.ofSeconds(30))
      .concurrency(10)
}

Contributing

See the contributing guide for more information

Packages

 
 
 

Contributors