Quarkus
Quarkus is a modern, JVM-based, fullstack framework, based on Vert.x HTTP engine.
Build configuration
Kilua RPC provides a single module for Quarkus, kilua-rpc-quarkus, which uses Quarkus dependency injection to access services implementations. You need to add this module to your project.
val commonMain by getting {
dependencies {
implementation("dev.kilua:kilua-rpc-quarkus:$kiluaRpcVersion")
}
}Service implementation
Service class
The implementation of the service class comes down to implementing required interface methods and making it a Quarkus @Dependent component.
@Dependent
class AddressService : IAddressService {
override suspend fun getAddressList(search: String?, sort: Sort) {
return listOf()
}
override suspend fun addAddress(address: Address) {
return Address()
}
override suspend fun updateAddress(id: Int, address: Address) {
return Address()
}
override suspend fun deleteAddress(id: Int) {
return false
}
}Injecting server objects
Quarkus DI solution (also called ArC) is based on the Jakarta Contexts and Dependency Injection 4.1 specification and allows you to inject resources and other Quarkus components into your service class. You can use standard @Inject annotation or constructor parameter injection.
Kilua RPC allows you to inject RoutingContext (a Vert.x class), which can also give you access to the user session.
Blocking code
Since Quarkus architecture is asynchronous and non-blocking, you should never block a thread in your application code. If you have to use some blocking code (e.g. blocking I/O, JDBC) always use the dedicated coroutine dispatcher.
Application configuration
The application class
To allow Kilua RPC work with Quarkus you have to pass all instances of the RpcServiceManager objects (defined in common code) to the Quarkus environment. You do this by defining a provider method for the RpcManagers instance in the main application class. You can use getAllServiceManagers() method to simplify your code.
The main method need to be located in the application subproject sources.
Last updated