Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Hoffer committed Nov 4, 2019
1 parent 705f07e commit 525ea99
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/main/java/polling/service/PollingServiceProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
import polling.common.StopExecutor;
import polling.interfaces.PollingService;

/**
* This is class is meant to be instantiated as a Bean, Component, or Service. The class's
* responsibilities are to manage the settings for polling and kick off new polling tasks. Other
* responsibilities include settings the wait and retry behavior. It also creates and configures the
* executor, and ensures that it is shutdown properly.
*/
@Service
@Slf4j
public class PollingServiceProvider implements PollingService {
Expand All @@ -30,13 +36,10 @@ public PollingServiceProvider() {
}

@Override
public <T> Future<T> poll(AttemptMaker<T> pollingTask) {
public <T> Future<T> poll(AttemptMaker<T> pollingTask) {

try {
return builder()
.polling(pollingTask)
.build()
.start();
return builder().polling(pollingTask).build().start();
} catch (Exception e) {
e.printStackTrace();
}
Expand All @@ -48,8 +51,7 @@ void destroy() {
new StopExecutor().stop(executorService);
}


PollerBuilder builder() {
PollerBuilder builder() {
return PollerBuilder.newBuilder()
.withExecutorService(executorService)
.stopIfException(false)
Expand Down

0 comments on commit 525ea99

Please sign in to comment.