Package-level declarations

持续会话上下文与会话管理。

持续会话上下文与会话管理。

Types

Link copied to clipboard

针对 ContinuousSessionContext 的基础抽象实现类。

Link copied to clipboard
fun interface AsyncInSession<C, T, R> : InSession<C, T, R>

以异步的API构造 InSession 实例。 可通过 InSessions.async 构造。

Link copied to clipboard
fun interface BlockInSession<C, T, R> : InSession<C, T, R>

以阻塞的API构造 InSession 实例。 可通过 InSessions.block 构造。

Link copied to clipboard

冲突的 session key.

Link copied to clipboard
Link copied to clipboard

持续会话(continuous session)管理器, 用于承载一组 ContinuousSessionProvider 和 ContinuousSessionReceiver 的上下文。用于构建与管理 ContinuousSession。

Link copied to clipboard
Link copied to clipboard

一组 Session 的元素之一, 用来向 ContinuousSessionReceiver 推送事件 T 并获悉结果 R 的“供应者”。

Link copied to clipboard

一组 Session 的元素之一, 用来在异步中接收 ContinuousSessionProvider 推送的事件 T 并根据此事件为其返回结果 R。

Link copied to clipboard
@RequiresOptIn(message = "This is an experimental api. It may be changed or removed in the future.", level = RequiresOptIn.Level.ERROR)
annotation class ExperimentalContinuousSessionAPI
Link copied to clipboard
fun interface InSession<C, T, R>

使用于 ContinuousSessionContext.session 中的 receiver 逻辑函数。

Link copied to clipboard
fun interface MonoInSession<C, T, R> : InSession<C, T, R>

以响应式风格 (Mono) 的API构造 InSession 实例。 可通过 InSessions.mono 构造。

Link copied to clipboard
sealed class MultipleAwaitResult<T>

因出现冲突的 session key 而被替换

Link copied to clipboard

当使用 ContinuousSessionProvider.push 推送成功、 但是在 ContinuousSessionReceiver.await 过程中出现异常时(例如构造返回给 push 的结果时出现异常) 则此异常会使用 SessionAwaitOnFailureException 进行包装。

Link copied to clipboard

当 Session 已经结束、但是某个 continuation 并未被恢复时,使用此异常恢复它。 如果 session 的结束伴随着异常,此异常会记录在 cause 中。

Link copied to clipboard

ContinuousSessionReceiver.await 的返回值类型, 可用来获取到本次等待到的 推送 结果, 并向其恢复一个结果或异常。

Link copied to clipboard

Functions

Link copied to clipboard
@JvmName(name = "async")
fun <C, T, R> asyncInSession(function: AsyncInSession<C, T, R>): InSession<C, T, R>

Java 友好 API,用于构造一个异步风格的 InSession 实例。

Link copied to clipboard
@JvmName(name = "block")
fun <C, T, R> blockInSession(context: CoroutineContext? = null, function: BlockInSession<C, T, R>): InSession<C, T, R>

Java 友好 API,用于构造一个阻塞风格的 InSession 实例。

Link copied to clipboard
@JvmName(name = "createContinuousSessionContext")
fun <T, R> ContinuousSessionContext(coroutineContext: CoroutineContext): ContinuousSessionContext<T, R>

创建一个 ContinuousSessionContext 的基础实现类型。

Link copied to clipboard
fun <C, T, R> createSimpleSessionContinuation(context: C, value: T, continuation: CancellableContinuation<R>, handle: DisposableHandle? = null): SessionContinuation<C, T, R>

构建一个基于 CancellableContinuation 实现的 SessionContinuation 实例。

Link copied to clipboard
@JvmName(name = "mono")
fun <C, T, R> monoInSession(function: MonoInSession<C, T, R>): InSession<C, T, R>

Java 友好 API,用于构造一个响应式风格 (Mono) 的 InSession 实例。

Inherited functions

Link copied to clipboard
suspend fun <C, T, R> ContinuousSessionReceiver<C, T, R>.awaitValue(result: R): T
Link copied to clipboard
inline suspend fun <C, T, R> ContinuousSessionReceiver<C, T, R>.awaitWith(block: (C, T) -> R)
Link copied to clipboard

进行多轮次处理。如果 block 的返回值类型不是 MultipleAwaitResult.Valid, 则 multipleAwaitWith 会继续 await 直到得到 MultipleAwaitResult.Valid 结果或产生了异常。

Link copied to clipboard
suspend fun <T, R> ContinuousSessionProvider<Unit, T, R>.push(value: T): R

推送一个事件到对应的 ContinuousSessionReceiver 中并挂起直到将其 消费 或被关闭。