Last active
January 17, 2018 22:04
-
-
Save rowanl/fdf9c378f33f138207497b064b9bd3bd to your computer and use it in GitHub Desktop.
playframework-kubernetes - Asynchronous, non-blocking implementation of find all query using Ebean
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private final EbeanServer ebeanServer; | |
private final DatabaseExecutionContext executionContext; | |
@Inject | |
public CharityRepository(EbeanConfig ebeanConfig, DatabaseExecutionContext executionContext, | |
@SuppressWarnings("unused") | |
EbeanDynamicEvolutions ebeanDynamicEvolutions /* Required for Ebean/DI bug */) { | |
this.ebeanServer = getServer(ebeanConfig.defaultServer()); | |
this.executionContext = executionContext; | |
} | |
private <T> CompletionStage<T> wrapContext(Supplier<T> toRun) { | |
return supplyAsync(toRun, executionContext); | |
} | |
public CompletionStage<List<Charity>> findList() { | |
return wrapContext(() -> ebeanServer.find(Charity.class).findList()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment