Support basic Java Executor interface
See original GitHub issueCurrently you can provide either ExecutorService
, ScheduledExecutorService
or implement custom Failsafe Scheduler
.
It would be good if it would also accept java.util.concurrent.Executor
interface since it is a common interface returned by other libs. My current use case is in gRPC, when splitting context for multi-threading, and gRPC methods #fixedContextExecutor return base Executor
.
Issue Analytics
- State:
- Created 4 years ago
- Comments:23 (2 by maintainers)
Top Results From Across the Web
Executor Interfaces - Java™ Tutorials - Oracle Help Center
This Java tutorial describes exceptions, basic input/output, concurrency, regular expressions, and the platform environment.
Read more >A Guide to the Java ExecutorService - Baeldung
An intro and guide to the ExecutorService framework provided by the JDK - which simplifies the execution of tasks in asynchronous mode.
Read more >What is Java Executor Framework? - GeeksforGeeks
Java executor framework (java.util.concurrent.Executor), released with the JDK 5 is used to run the Runnable objects without creating new ...
Read more >Guide to ExecutorService in Java - HowToDoInJava
ExecutorService is an interface and its implementations can execute a Runnable or Callable class in an asynchronous way. Note that invoking the ...
Read more >Java ExecutorService and Thread Pools Tutorial - CalliCoder
Executors Framework · Executor - A simple interface that contains a method called execute() to launch a task specified by a Runnable object....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Seems reasonable to me. At the very least, couldn’t the use of
ExecutorService.submit
in lines like this be replaced by something like:when
es
is anExecutor
but not anExecutableService
? I realize that I’m glossing over an important detail with the following simple implementation ofcallableToSupplier
, but the general idea seems feasible:@paulius-p So there are two options for approaching this problem:
Executor
call the user-provided Supplier/Runnable directly, then the result of the Executor is recorded. Of course this result would always benull
or an exception. This is what the current Failsafe implementation does.Executor
call a Runnable that wraps not just the user-provided Supplier/Runnable, but also the Failsafe code that records its result. This way the result from the Executor doesn’t matter, it’s just there for performing side-effects if needed, almost like an event listener. Also, if the Executor throws an exception, it won’t be recorded as part of the Failsafe handling since recording a result happens before theExecutor
completes. This is what your commit does.I’m guessing you’d prefer the second option? When you say things partially works now, is that because using an
Executor
returnsnull
currently? Maybe you could share your thoughts on the options.