Closed adutra closed 3 years ago
Alternatively we can explore the idea of exposing two beans: CompletionStage<QuarkusCqlSession>
and QuarkusCqlSession
, something like:
@Produces
@ApplicationScoped
@Unremovable
public CompletionStage<QuarkusCqlSession> createCassandraClientAsync() {
...
QuarkusCqlSessionBuilder builder =
new QuarkusCqlSessionBuilder()
.withMetricRegistry(metricRegistry)
.withQuarkusEventLoop(mainEventLoop)
.withConfigLoader(configLoaderBuilder.build());
return builder.buildAsync();
}
@Produces
@ApplicationScoped
@Unremovable
public QuarkusCqlSession createCassandraClient(CompletionStage<QuarkusCqlSession> sessionFuture) {
return CompletableFutures.getUninterruptibly(sessionFuture);
}
Note that this may be complicated by the presence of mapper/daos, since these components would have to be produced as CompletionStage<...>
as well.
Instead of injecting
CompletionStage<QuarkusCqlSession>
we could provide a session wrapper so that users can injectQuarkusCqlSession
directly and avoid blocking Vertx threads even if they opt out from eager init at startup.┆Issue is synchronized with this Jira Task by Unito