CompletableFutureMemoryService

Java-friendly wrapper around a MemoryService 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 addEventsToMemory(appName: String, userId: String, events: List<Event>, sessionId: String? = null, customMetadata: Map<String, Any?>? = null, coroutineContext: CoroutineContext = EmptyCoroutineContext): CompletableFuture<Void?>

Calls MemoryService.addEventsToMemory. The future fails with UnsupportedOperationException if the service does not support event deltas.

Link copied to clipboard
fun addMemory(appName: String, userId: String, memories: List<MemoryEntry>, customMetadata: Map<String, Any?>? = null, coroutineContext: CoroutineContext = EmptyCoroutineContext): CompletableFuture<Void?>

Calls MemoryService.addMemory. The future fails with UnsupportedOperationException if the service does not support direct memory writes.

Link copied to clipboard
fun addSessionToMemory(session: Session, coroutineContext: CoroutineContext = EmptyCoroutineContext): CompletableFuture<Void?>
Link copied to clipboard

The wrapped memory 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 searchMemory(appName: String, userId: String, query: String, coroutineContext: CoroutineContext = EmptyCoroutineContext): CompletableFuture<SearchMemoryResponse>