Interface ExecStarter
-
- All Superinterfaces:
ExecSpec
public interface ExecStarter extends ExecSpec
Starts a newExecution
.- See Also:
Execution.fork()
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description ExecStarter
eventLoop(io.netty.channel.EventLoop eventLoop)
Specifies that the execution must run on the given event loop.ExecStarter
onComplete(Action<? super Execution> onComplete)
Specifies the completion callback for the execution.ExecStarter
onError(Action<? super Throwable> onError)
Specify the top level error handler for the execution.ExecStarter
onStart(Action<? super Execution> onStart)
Specifies an action to be taken just before the execution starts.ExecStarter
register(Action<? super RegistrySpec> action)
Populates the execution's registry.default void
start(Operation operation)
Starts the execution, and executes the given operation.void
start(Action<? super Execution> initialExecutionSegment)
Starts the execution, with the given action as the initial segment.
-
-
-
Method Detail
-
start
@NonBlocking void start(Action<? super Execution> initialExecutionSegment)
Starts the execution, with the given action as the initial segment.- Parameters:
initialExecutionSegment
- the initial execution segment of the execution
-
start
@NonBlocking default void start(Operation operation)
Starts the execution, and executes the given operation.- Parameters:
operation
- the operation to execute- Since:
- 1.4
-
onError
ExecStarter onError(Action<? super Throwable> onError)
Specify the top level error handler for the execution.The given action will be invoked with any exceptions that are thrown and not handled.
import ratpack.exec.Execution; import ratpack.exec.Promise; import ratpack.test.exec.ExecHarness; import static org.junit.jupiter.api.Assertions.assertEquals; public class Example { public static void main(String... args) throws Exception { String value = ExecHarness.<String>yieldSingle(e -> Promise.async(d -> Execution.fork() .onError(t -> d.success("global error handler")) .start(e1 -> Promise.error(new RuntimeException("bang1")) .then(v -> d.success("should not be called")) ) )).getValue(); assertEquals(value, "global error handler"); } }
-
onComplete
ExecStarter onComplete(Action<? super Execution> onComplete)
Specifies the completion callback for the execution.The given action will effectively execute outside of the execution. The action is expected to be synchronous and cannot perform async operations. During its execution, there will be no thread bound execution or execution control. Any exceptions raised will be logged.
This method should be used as a last resort.
The action will be invoked regardless of whether the execution completed with an error or not. If the execution did complete with an error, the given action will be invoked after the error handler.
This method is not additive. That is, any subsequent calls replace the previous value.
- Specified by:
onComplete
in interfaceExecSpec
- Parameters:
onComplete
- the action to invoke when the execution completes.- Returns:
this
-
onStart
ExecStarter onStart(Action<? super Execution> onStart)
Specifies an action to be taken just before the execution starts.The action will be invoked after
ExecSpec.register(Action)
and anyExecInitializer
's.The
current execution
during the given callback is the parent execution of the new execution being started. If the execution is being created from outside of an execution, there will be no current execution during the callback.This method is not additive. That is, any subsequent calls replace the previous value.
-
register
ExecStarter register(Action<? super RegistrySpec> action)
Populates the execution's registry.The
current execution
during the given callback is the parent execution of the new execution being started. If the execution is being created from outside of an execution, there will be no current execution during the callback.This method is not additive. That is, any subsequent calls replace the previous value.
-
eventLoop
ExecStarter eventLoop(io.netty.channel.EventLoop eventLoop)
Specifies that the execution must run on the given event loop.If this method is not called, an event loop will be automatically assigned from the
exec controller's event loop group
. It is generally not required, or desirable, to call this method.
-
-