Skip to content

Commit

Permalink
#72 Test homework publication
Browse files Browse the repository at this point in the history
  • Loading branch information
vityaman committed Jun 13, 2024
1 parent d31b578 commit dec87a7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ru.vityaman.lms.botalka.core.logging.Log
import ru.vityaman.lms.botalka.core.publication.task.PublicationTask

fun loggingPublicationCallbacks(log: Log) = PublicationTask.Callbacks(
onStart = { log.info("Starting...") },
onStart = { log.info("Starting with now as '$it'...") },
onReceived = { log.info("Received ${it.size} homeworks") },
onNext = { log.info("Publishing homework with id ${it.id}...") },
onAccepted = { log.info("Published homework with id ${it.id}") },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ class PublicationTask(
private val callbacks: Callbacks = Callbacks(),
) : Runnable {
override suspend fun run() {
callbacks.onStart()
homeworks.publishableAt(OffsetDateTime.now(clock))
val now = OffsetDateTime.now(clock)
callbacks.onStart(now)
homeworks.publishableAt(now)
.toCollection(mutableListOf())
.shuffled()
.also { callbacks.onReceived(it) }
Expand All @@ -38,7 +39,7 @@ class PublicationTask(
}

data class Callbacks(
val onStart: suspend () -> Unit = {},
val onStart: suspend (OffsetDateTime) -> Unit = {},
val onReceived: suspend (List<Homework.Id>) -> Unit = {},
val onNext: suspend (Homework) -> Unit = {},
val onAccepted: suspend (Homework) -> Unit = {},
Expand Down
2 changes: 2 additions & 0 deletions botalka/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ logging:
r2dbc: INFO
sql: INFO
web: INFO
kafka: WARN
group:
r2dbc: org.springframework.r2dbc,org.springframework.data.r2dbc
kafka: org.apache.kafka
management:
endpoints:
web:
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml → compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ services:
broker:
container_name: lms-broker
image: apache/kafka
restart: always
environment:
KAFKA_NODE_ID: 1
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: 'CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT'
Expand Down

0 comments on commit dec87a7

Please sign in to comment.