Class CapturedContextSupport
java.lang.Object
dev.langchain4j.invocation.CapturedContextSupport
Carries the context of the thread that started an AI Service invocation, captured with
ExecutorProvider.captureContext(), in the InvocationContext of the invocation, so that every task
the invocation offloads runs with it, whichever thread submits the task.-
Method Summary
Modifier and TypeMethodDescriptionstatic InvocationContext.BuildercaptureInto(InvocationContext.Builder builder) Captures the context of the calling thread into the given builder, if anExecutorProviderthat captures context is registered.static ExecutorrestoringIn(Executor executor, InvocationContext invocationContext)
-
Method Details
-
captureInto
Captures the context of the calling thread into the given builder, if anExecutorProviderthat captures context is registered.- Returns:
- the given builder
-
restoringIn
- Returns:
- an executor that submits tasks to the given executor, running them with the context captured when the given invocation started; the given executor itself if nothing was captured
-