- All Implemented Interfaces:
Serializable
,Comparable<ExecutionMode>
,Constable
Execution mode.
- Author:
- edgar
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionDefault execution mode.Execute route handler in the event loop thread (non-blocking).Execute handler in a worker/io thread (blocking). -
Method Summary
Modifier and TypeMethodDescriptionstatic ExecutionMode
Returns the enum constant of this class with the specified name.static ExecutionMode[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Enum Constant Details
-
EVENT_LOOP
Execute route handler in the event loop thread (non-blocking). Handler must never block.Examples:
{ mode(EVENT_LOOP); get("/non-blocking", ctx -> "I'm running on event-loop thread (no blocking allowed)"); // Dispatch to worker thread, blocking routes dispatch(() -> { get("/blocking", ctx -> { // remote call: service, database, etc.. return "Safe to block"; }); }); }
-
WORKER
Execute handler in a worker/io thread (blocking). Handler is allowed to block.Examples:
{ mode(WORKER); get("/worker", ctx -> { // remote call: another service, database, etc.. return "Safe to block"; }); }
-
DEFAULT
Default execution mode.Automatically choose between
EVENT_LOOP
andWORKER
.If route handler returns a `reactive` type, then Jooby run the route handler in the event-loop thread. Otherwise, run the handler in the worker thread.
A reactive type is one of:
-
CompletableFuture
. - A reactive stream Publisher - Rx types: Observable, Flowable, Single, Maybe, etc.. - Reactor types: Flux and Mono.Examples:
{ get("/non-blocking", ctx -> { return CompletableFuture.supplyAsync(() -> { return "I'm non-blocking"; }); }); get("/blocking", ctx -> { return "I'm blocking"; }); }
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-