Event Loop
SmallRye Fault Tolerance provides an API to integrate with event loops used in non-blocking runtimes.
This integration API comes from the core module and so is treated as private.
If you intend to implement it, please let us know in the SmallRye Fault Tolerance issue tracker.
We’d prefer all the implementations to live in the SmallRye Fault Tolerance project.
|
The integrator must implement the EventLoop
interface, which lets SmallRye Fault Tolerance submit Runnable
s to the event loop for execution.
Implementations are discovered through ServiceLoader
, so the corresponding META-INF/services/...
file must also exist.
At most one implementation of EventLoop
may be present at runtime.
SmallRye Fault Tolerance will use it to execute non-blocking guarded methods when the caller was originally on an event loop thread.
This is important in case of:
-
retries, when there’s a delay between retry attempts (the delay must not block);
-
bulkheads, when a task is queued (such task is executed when some other task finishes, which happens on an unknown thread).
If no event loop integration is present, the tasks described above will be offloaded to the thread pool.
Vert.x
SmallRye Fault Tolerance includes an implementation of the event loop integration API for Vert.x. This implementation is compiled and tested against Vert.x version 4.4.1, but should also work fine with Vert.x 3.x.
This implementation is present in the io.smallrye:smallrye-fault-tolerance-vertx
artifact.
Including this artifact is enough to enable the Vert.x integration.
The Vert.x implementation is treated as public, but only as described here. That is, the artifact should be treated as opaque, no guarantees about its internals are made. |