feat(server): real GET /sessions via SessionSummaryProjector
This commit is contained in:
@@ -23,6 +23,8 @@ import com.correx.core.kernel.orchestration.OrchestrationConfig
|
|||||||
import com.correx.core.kernel.orchestration.OrchestrationRepository
|
import com.correx.core.kernel.orchestration.OrchestrationRepository
|
||||||
import com.correx.core.router.RouterFacade
|
import com.correx.core.router.RouterFacade
|
||||||
import com.correx.core.sessions.DefaultSessionRepository
|
import com.correx.core.sessions.DefaultSessionRepository
|
||||||
|
import com.correx.core.sessions.SessionSummary
|
||||||
|
import com.correx.core.sessions.SessionSummaryProjector
|
||||||
import com.correx.core.tools.registry.ToolRegistry
|
import com.correx.core.tools.registry.ToolRegistry
|
||||||
import com.correx.core.events.orchestration.OrchestrationStatus
|
import com.correx.core.events.orchestration.OrchestrationStatus
|
||||||
import kotlinx.datetime.Clock
|
import kotlinx.datetime.Clock
|
||||||
@@ -224,6 +226,13 @@ class ServerModule(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val sessionSummaryProjector = SessionSummaryProjector()
|
||||||
|
|
||||||
|
fun listSessionSummaries(): List<SessionSummary> =
|
||||||
|
eventStore.allSessionIds().map { sessionId ->
|
||||||
|
sessionSummaryProjector.project(sessionId, eventStore.readFrom(sessionId, fromSequence = 0L))
|
||||||
|
}
|
||||||
|
|
||||||
private fun preRegisterPendingApprovals() {
|
private fun preRegisterPendingApprovals() {
|
||||||
val projector = ApprovalProjector(DefaultApprovalReducer())
|
val projector = ApprovalProjector(DefaultApprovalReducer())
|
||||||
eventStore.allSessionIds().forEach { sessionId ->
|
eventStore.allSessionIds().forEach { sessionId ->
|
||||||
|
|||||||
@@ -21,7 +21,15 @@ import java.util.*
|
|||||||
data class StartSessionRequest(val workflowId: String, val config: SessionConfigDto? = null)
|
data class StartSessionRequest(val workflowId: String, val config: SessionConfigDto? = null)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SessionSummaryResponse(val sessionId: String, val status: String)
|
data class SessionSummaryResponse(
|
||||||
|
val sessionId: String,
|
||||||
|
val status: String,
|
||||||
|
val intent: String? = null,
|
||||||
|
val workflowId: String? = null,
|
||||||
|
val stageCount: Int = 0,
|
||||||
|
val createdAt: String? = null,
|
||||||
|
val lastActivityAt: String? = null,
|
||||||
|
)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SessionStateResponse(val sessionId: String, val status: String, val createdAt: String?)
|
data class SessionStateResponse(val sessionId: String, val status: String, val createdAt: String?)
|
||||||
@@ -37,7 +45,20 @@ private val log = LoggerFactory.getLogger("com.correx.apps.server.routes.Session
|
|||||||
fun Route.sessionRoutes(module: ServerModule) {
|
fun Route.sessionRoutes(module: ServerModule) {
|
||||||
val streamHandler = SessionStreamHandler(module)
|
val streamHandler = SessionStreamHandler(module)
|
||||||
route("/sessions") {
|
route("/sessions") {
|
||||||
get { call.respond(emptyList<SessionSummaryResponse>()) }
|
get {
|
||||||
|
val summaries = module.listSessionSummaries().map { s ->
|
||||||
|
SessionSummaryResponse(
|
||||||
|
sessionId = s.sessionId.value,
|
||||||
|
status = s.status,
|
||||||
|
intent = s.intent,
|
||||||
|
workflowId = s.workflowId,
|
||||||
|
stageCount = s.stageCount,
|
||||||
|
createdAt = s.createdAt?.toString(),
|
||||||
|
lastActivityAt = s.lastActivityAt?.toString(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
call.respond(summaries)
|
||||||
|
}
|
||||||
startSessionRoute(module)
|
startSessionRoute(module)
|
||||||
route("/{id}") {
|
route("/{id}") {
|
||||||
getSessionRoute(module)
|
getSessionRoute(module)
|
||||||
|
|||||||
Reference in New Issue
Block a user