KandraProcessor

class KandraProcessor(codeGenerator: CodeGenerator, logger: KSPLogger) : SymbolProcessor

KSP processor that generates a type-safe *Table object for every @ScyllaTable class, and — conditionally, only when detected on the consuming module's compilation classpath — typed Koin/Kodein DI accessor functions for that same entity.

For an entity:

@ScyllaTable("users")
data class User(@PartitionKey val userId: UUID, ...)

It emits UserTable.kt in the same package:

// GENERATED BY KANDRA — DO NOT EDIT
object UserTable : KandraTable<User> {
val userId = KandraColumnRef<UUID>("user_id")
...
}

If org.koin.core.component.KoinComponent resolves on this compilation's classpath, it also emits UserKoinDi.kt:

fun KoinComponent.userRepo(): KandraRepository<User> =
get<KandraRepository<*>>(named("UserRepo")) as KandraRepository<User>
fun KoinComponent.userSuspendRepo(): KandraSuspendRepository<User> =
get<KandraSuspendRepository<*>>(named("UserSuspendRepo")) as KandraSuspendRepository<User>

If org.kodein.di.DIAware resolves on this compilation's classpath, it also emits UserKodeinDi.kt:

fun DIAware.userRepo(): KandraRepository<User> =
direct.instance<KandraRepository<*>>(tag = "User") as KandraRepository<User>
fun DIAware.userSuspendRepo(): KandraSuspendRepository<User> =
direct.instance<KandraSuspendRepository<*>>(tag = "UserSuspend") as KandraSuspendRepository<User>

Detection is purely presence-based (a classpath probe via Resolver.getClassDeclarationByName); this module never takes a compile dependency on koin-core or kodein-di itself — the DI marker types are referenced only as raw fully-qualified strings spliced into generated source, exactly like kandra-runtime's types already are for the *Table object. Neither Koin nor Kodein present is the common case (e.g. this repo's own module graph) and is not an error or a warning — it's simply skipped for that entity.

The generated qualifier/tag strings are load-bearing: they must match kandra-koin's Application.kandraKoin() ("${'$'}{Entity}Repo" / "${'$'}{Entity}SuspendRepo") and kandra-kodein's Application.kandraKodein() ("${'$'}{Entity}" / "${'$'}{Entity}Suspend") exactly, since these accessors exist only to retrieve the exact bindings those files create.

Constructors

Link copied to clipboard
constructor(codeGenerator: CodeGenerator, logger: KSPLogger)

Functions

Link copied to clipboard
open fun finish()
Link copied to clipboard
open fun onError()
Link copied to clipboard
open override fun process(resolver: Resolver): List<KSAnnotated>