class JooqTaskRelocationResultStore implements TaskRelocationResultStore {

    @Override
    public Mono<Map<String, Optional<Throwable>>> createTaskRelocationStatuses(List<TaskRelocationStatus> taskRelocationStatuses) {
        return Mono.defer(() -> {
            CompletionStage<int[]> asyncAction = JooqUtils.executeAsync(() -> {
                        loadToCache(findNotCached(taskRelocationStatuses), dslContext.configuration());

                        List<StoreQuery<JRelocationStatusRecord>> queries = taskRelocationStatuses.stream()
                                .map(this::newCreateOrUpdateQuery)
                                .collect(Collectors.toList());

                        return dslContext
                                .batch(queries)
                                .execute();
                    }, dslContext);

            MonoProcessor<Map<String, Optional<Throwable>>> callerProcessor = MonoProcessor.create();
            asyncAction.handle((result, error) -> {
                Map<String, Optional<Throwable>> resultMap = new HashMap<>();
                if (error == null) {
                    taskRelocationStatuses.forEach(p -> {
                        resultMap.put(p.getTaskId(), Optional.empty());
                        statusesByTaskId.put(p.getTaskId(), p);
                    });

                    callerProcessor.onNext(resultMap);
                } else {
                    callerProcessor.onError(error);
                }
                return null;
            });

            return callerProcessor;
        });
    }

    @Inject public  JooqTaskRelocationResultStore(DSLContext dslContext, TitusRuntime titusRuntime);

}