Class HandlerRunner.Options
- All Implemented Interfaces:
HandlerRunner.Options
- Enclosing class:
HandlerRunner<REQ,RES>
HandlerRunner options, to configure the executor to use to run your services, and the
interceptors.
By default, executor will be configured to use virtual threads on Java 21+, or fallback to
Executors.newCachedThreadPool() for Java < 21. The bounded pool is shared among all
HandlerRunner instances, and is used by Restate.run(java.lang.String, java.lang.Class<T>, dev.restate.common.function.ThrowingSupplier<T>)/Context.run(java.lang.String, java.lang.Class<T>, dev.restate.common.function.ThrowingSupplier<T>) as
well.
HandlerInterceptor.Factory and RunInterceptor.Factory registered via SPI are
also loaded by default.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final HandlerRunner.OptionsDeprecated, for removal: This API element is subject to removal in a future version.Create a new instance of Options instead. -
Constructor Summary
ConstructorsConstructorDescriptionOptions()Create new options, checkHandlerRunner.Optionsfor the defaults documentation. -
Method Summary
Modifier and TypeMethodDescriptionAppend aHandlerInterceptor.Factoryto the factories, as innermost in the chain.addRunContextPropagator(RunContextPropagator propagator) Append aRunContextPropagator.Append aRunInterceptor.Factoryto the factories, as innermost in the chain.executor()setExecutor(Executor executor) Set the givenexecutoras the handler executor.setHandlerInterceptorFactories(List<HandlerInterceptor.Factory> newFactories) Overwrite theHandlerInterceptor.Factorychain with a new chain.setRunContextPropagators(List<RunContextPropagator> newPropagators) Overwrite theRunContextPropagatorlist.setRunInterceptorFactories(List<RunInterceptor.Factory> newFactories) Overwrite theRunInterceptor.Factorychain with a new chain.static HandlerRunner.OptionswithExecutor(Executor executor) Create an instance ofHandlerRunner.Optionswith the givenexecutor.
-
Field Details
-
DEFAULT
Deprecated, for removal: This API element is subject to removal in a future version.Create a new instance of Options instead.
-
-
Constructor Details
-
Options
public Options()Create new options, checkHandlerRunner.Optionsfor the defaults documentation.
-
-
Method Details
-
withExecutor
Create an instance ofHandlerRunner.Optionswith the givenexecutor.The given executor is used for running the handler code, and
Restate.run(java.lang.String, java.lang.Class<T>, dev.restate.common.function.ThrowingSupplier<T>)/Context.run(java.lang.String, java.lang.Class<T>, dev.restate.common.function.ThrowingSupplier<T>)as well. -
setExecutor
Set the givenexecutoras the handler executor.The given executor is used for running the handler code, and
Restate.run(java.lang.String, java.lang.Class<T>, dev.restate.common.function.ThrowingSupplier<T>)/Context.run(java.lang.String, java.lang.Class<T>, dev.restate.common.function.ThrowingSupplier<T>)as well.- Returns:
- self for fluency
-
addHandlerInterceptorFactory
Append aHandlerInterceptor.Factoryto the factories, as innermost in the chain.- Returns:
- self for fluency
-
addRunInterceptorFactory
Append aRunInterceptor.Factoryto the factories, as innermost in the chain.- Returns:
- self for fluency
-
setHandlerInterceptorFactories
public HandlerRunner.Options setHandlerInterceptorFactories(List<HandlerInterceptor.Factory> newFactories) Overwrite theHandlerInterceptor.Factorychain with a new chain.- Returns:
- self for fluency
-
setRunInterceptorFactories
Overwrite theRunInterceptor.Factorychain with a new chain.- Returns:
- self for fluency
-
addRunContextPropagator
Append aRunContextPropagator. Propagators capture thread-local state atRestate.run(java.lang.String, java.lang.Class<T>, dev.restate.common.function.ThrowingSupplier<T>)submission and restore it around the closure execution on the worker thread. The first registered propagator captures/restores outermost.- Returns:
- self for fluency
-
setRunContextPropagators
Overwrite theRunContextPropagatorlist.- Returns:
- self for fluency
-
executor
-
handlerInterceptorFactories
-
runInterceptorFactories
-
runContextPropagators
-