CompletableFutureSessionService

Java-friendly wrapper around a SessionService that it owns: each method calls the suspend method of the same name and returns a CompletableFuture of its result, so Java callers never pass a Continuation. Each call runs in the caller's OpenTelemetry context and in the coroutineContext passed to it, such as MDCContext() from kotlinx-coroutines-slf4j to carry the caller's MDC. Canceling a future cancels its call, a Job in coroutineContext is ignored, and close cancels every call in flight, then closes the service if it is AutoCloseable.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun appendEvent(session: Session, event: Event, coroutineContext: CoroutineContext = EmptyCoroutineContext): CompletableFuture<Event>

Calls SessionService.appendEvent, which updates session in place on another thread, so leave session alone until the future completes.

Link copied to clipboard

The wrapped session service, for code that has dropped into Kotlin.

Link copied to clipboard
open override fun close()

Cancels calls in flight, then closes the service if it is AutoCloseable. Every later call returns a canceled future.

Link copied to clipboard
fun closeSession(session: Session, coroutineContext: CoroutineContext = EmptyCoroutineContext): CompletableFuture<Void?>
Link copied to clipboard
fun createSession(key: SessionKey, state: Map<String, Any>? = null, coroutineContext: CoroutineContext = EmptyCoroutineContext): CompletableFuture<Session>
Link copied to clipboard
fun deleteSession(key: SessionKey, coroutineContext: CoroutineContext = EmptyCoroutineContext): CompletableFuture<Void?>
Link copied to clipboard
fun flush(key: SessionKey? = null, coroutineContext: CoroutineContext = EmptyCoroutineContext): CompletableFuture<Void?>
Link copied to clipboard
fun getSession(key: SessionKey, config: GetSessionConfig? = null, coroutineContext: CoroutineContext = EmptyCoroutineContext): CompletableFuture<Session?>

Calls SessionService.getSession; the future completes with null if there is no session.

Link copied to clipboard
Link copied to clipboard
fun listSessions(appName: String, userId: String, coroutineContext: CoroutineContext = EmptyCoroutineContext): CompletableFuture<ListSessionsResponse>