This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": "test", | |
"realm": "test", | |
"notBefore": 0, | |
"revokeRefreshToken": false, | |
"refreshTokenMaxReuse": 0, | |
"accessTokenLifespan": 300, | |
"accessTokenLifespanForImplicitFlow": 900, | |
"ssoSessionIdleTimeout": 1800, | |
"ssoSessionMaxLifespan": 36000, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main(args: Array<String>) { | |
val ioRepository: EmployeeRepository<ForIO> = DeferEmployeeRepository(RequeryDatabase.store, IO.monadDefer()) | |
val rx2Repository: EmployeeRepository<ForSingleK> = SingleKEmployeeRepository(RequeryDatabase.reactiveStore) | |
val ioRouting = EmployeeRouting(ioRepository, IO.suspendable()) | |
val rx2Routing = EmployeeRouting(rx2Repository, SingleK.suspendable()) | |
val server = embeddedServer(Netty, port = 8080) { | |
configureJsonSerialization() | |
install(Routing) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun SingleK.Companion.suspendable(): Suspendable<ForSingleK> = object: Suspendable<ForSingleK> { | |
override suspend fun <A: Any> Kind<ForSingleK, A>.suspended(): A { | |
val single = this.fix().value() | |
return suspendCoroutine { | |
single.subscribe(it::resume, it::resumeWithException) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SingleKEmployeeRepository( | |
private val reactiveStore: KotlinReactiveEntityStore<Persistable>): EmployeeRepository<ForSingleK> { | |
override fun findAll(): SingleKOf<List<Employee>> = reactiveStore | |
.select(Employee::class) | |
.get() | |
.flowable() | |
.toList() | |
.k() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main(args: Array<String>) { | |
val employeeRepository: EmployeeRepository<ForIO> = DeferEmployeeRepository(RequeryDatabase.store, IO.monadDefer()) | |
val employeeRouting = EmployeeRouting(employeeRepository, IO.suspendable()) | |
val server = embeddedServer(Netty, port = 8080) { | |
configureJsonSerialization() | |
install(Routing) { | |
with(employeeRouting) { employees("/employees") } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object RequeryDatabase { | |
private fun initDatasource(): DataSource { | |
val ds = JdbcDataSource() | |
ds.setURL("jdbc:h2:mem:requery;DB_CLOSE_DELAY=-1") | |
createTableAndInsertSampleData(ds) | |
return ds | |
} | |
private fun createTableAndInsertSampleData(ds: JdbcDataSource) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Entity(immutable = true) | |
data class Employee ( | |
@get:Key @get:Generated val id: Long, | |
@get:Column(name = "first_name") val firstName: String, | |
@get:Column(name = "last_name") val lastName: String | |
): Persistable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DeferEmployeeRepository<F>( | |
private val store: KotlinEntityDataStore<Persistable>, | |
private val monadDefer: MonadDefer<F>): EmployeeRepository<F> { | |
override fun findAll(): Kind<F, List<Employee>> = monadDefer.later { | |
store.invoke { | |
select(Employee::class) | |
.get() | |
.toList() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MockEmployeeRepository(private val list: List<Employee>): EmployeeRepository<ForId> { | |
override fun findAll(): Id<List<Employee>> = Id.just(list) | |
} | |
fun Id.Companion.suspendable(): Suspendable<ForId> = object: Suspendable<ForId> { | |
override suspend fun <A : Any> Kind<ForId, A>.suspended(): A { | |
val id = this.fix() | |
return id.extract() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main(args: Array<String>) { | |
val employeeRouting = EmployeeRouting(IOEmployeeRepository(), IO.suspendable()) | |
val server = embeddedServer(Netty, port = 8080) { | |
configureJsonSerialization() | |
install(Routing) { | |
with(employeeRouting) { employees("/employees") } | |
} | |
} | |
server.start(wait = true) |
NewerOlder