@PostMapping("/single") public Completable createWithSingle(@RequestBody Single<Person> single) { return single.map(persons::add).toCompletable(); }
conn .rxExecute(sql).toCompletable()
@Override public Completable unpublish(ServiceDiscovery discovery) { return discovery.rxUnpublish(registrationId).toCompletable(); } }
private Completable ensureMapping() { // merge mappings from all indexers Map<String, Object> mappings = new HashMap<>(); indexerFactories.stream().filter(f -> f instanceof DefaultMetaIndexerFactory) .forEach(factory -> MapUtils.deepMerge(mappings, factory.getMapping())); indexerFactories.stream().filter(f -> !(f instanceof DefaultMetaIndexerFactory)) .forEach(factory -> MapUtils.deepMerge(mappings, factory.getMapping())); return client.putMapping(TYPE_NAME, new JsonObject(mappings)).toCompletable(); }
private Completable ensureMapping() { // merge mappings from all indexers Map<String, Object> mappings = new HashMap<>(); indexerFactories.stream().filter(f -> f instanceof DefaultMetaIndexerFactory) .forEach(factory -> MapUtils.deepMerge(mappings, factory.getMapping())); indexerFactories.stream().filter(f -> !(f instanceof DefaultMetaIndexerFactory)) .forEach(factory -> MapUtils.deepMerge(mappings, factory.getMapping())); return client.putMapping(TYPE_NAME, new JsonObject(mappings)).toCompletable(); }
@Override public Observable<T> call(Observable<T> upstream) { return sqlConnection.rxSetAutoCommit(false).toCompletable() .andThen(upstream) .concatWith(sqlConnection.rxCommit().toCompletable().toObservable()) .onErrorResumeNext(throwable -> { return sqlConnection.rxRollback().toCompletable().onErrorComplete() .andThen(sqlConnection.rxSetAutoCommit(true).toCompletable().onErrorComplete()) .andThen(Observable.error(throwable)); }).concatWith(sqlConnection.rxSetAutoCommit(true).toCompletable().toObservable()); } }
@Override public Observable<T> call(Observable<T> upstream) { return sqlConnection.rxSetAutoCommit(false).toCompletable() .andThen(upstream) .concatWith(sqlConnection.rxCommit().toCompletable().toObservable()) .onErrorResumeNext(throwable -> { return sqlConnection.rxRollback().toCompletable().onErrorComplete() .andThen(sqlConnection.rxSetAutoCommit(true).toCompletable().onErrorComplete()) .andThen(Observable.error(throwable)); }).concatWith(sqlConnection.rxSetAutoCommit(true).toCompletable().toObservable()); } }
@Override public Completable call(Completable upstream) { return sqlConnection.rxSetAutoCommit(false).toCompletable() .andThen(upstream) .andThen(sqlConnection.rxCommit().toCompletable()) .onErrorResumeNext(throwable -> { return sqlConnection.rxRollback().toCompletable().onErrorComplete() .andThen(sqlConnection.rxSetAutoCommit(true).toCompletable().onErrorComplete()) .andThen(Completable.error(throwable)); }).andThen(sqlConnection.rxSetAutoCommit(true).toCompletable()); } }
@Override public Completable call(Completable upstream) { return sqlConnection.rxSetAutoCommit(false).toCompletable() .andThen(upstream) .andThen(sqlConnection.rxCommit().toCompletable()) .onErrorResumeNext(throwable -> { return sqlConnection.rxRollback().toCompletable().onErrorComplete() .andThen(sqlConnection.rxSetAutoCommit(true).toCompletable().onErrorComplete()) .andThen(Completable.error(throwable)); }).andThen(sqlConnection.rxSetAutoCommit(true).toCompletable()); } }
/** * Rx version of {@link #delete(String, String, DeleteMeta, Handler)} * @param search the search query * @param path the path where to search for the chunks (may be null) * @param deleteMeta a metadata object containing additional information * about the deletion process * @return a Completable that completes when the operation has finished */ public Completable rxDelete(String search, String path, DeleteMeta deleteMeta) { return Single.create(new SingleOnSubscribeAdapter<Void>(f -> delete(search, path, deleteMeta, f))).toCompletable(); }
/** * Rx version of {@link #appendTags(String, String, List, Handler)} * @param search the search query * @param path the path where to search for the values (may be null) * @param tags the list of tags to append * @return a Completable that completes when the operation has finished */ public Completable rxAppendTags(String search, String path, List<String> tags) { return Single.create(new SingleOnSubscribeAdapter<Void>(f -> appendTags(search, path, tags, f))).toCompletable(); }
/** * Rx version of {@link #setProperties(String, String, Map, Handler)} * @param search the search query * @param path the path where to search for the values (may be null) * @param properties the list of properties to set * @return a Completable that completes when the operation has finished */ public Completable rxSetProperties(String search, String path, Map<String, String> properties) { return Single.create(new SingleOnSubscribeAdapter<Void>(f -> setProperties(search, path, properties, f))).toCompletable(); }
/** * Rx version of {@link #removeProperties(String, String, List, Handler)} * @param search the search query * @param path the path where to search for the values (may be null) * @param properties the list of properties to remove * @return a Completable that completes when the operation has finished */ public Completable rxRemoveProperties(String search, String path, List<String> properties) { return Single.create(new SingleOnSubscribeAdapter<Void>(f -> removeProperties(search, path, properties, f))).toCompletable(); }
/** * Rx version of {@link #removeTags(String, String, List, Handler)} * @param search the search query * @param path the path where to search for the values (may be null) * @param tags the list of tags to remove * @return a Completable that completes when the operation has finished */ public Completable rxRemoveTags(String search, String path, List<String> tags) { return Single.create(new SingleOnSubscribeAdapter<Void>(f -> removeTags(search, path, tags, f))).toCompletable(); } }
@Override public Single<T> call(Single<T> upstream) { return sqlConnection.rxSetAutoCommit(false).toCompletable() .andThen(upstream) .flatMap(item -> sqlConnection.rxCommit().toCompletable().andThen(Single.just(item))) .onErrorResumeNext(throwable -> { return sqlConnection.rxRollback().toCompletable().onErrorComplete() .andThen(sqlConnection.rxSetAutoCommit(true).toCompletable().onErrorComplete()) .andThen(Single.error(throwable)); }).flatMap(item -> sqlConnection.rxSetAutoCommit(true).toCompletable().andThen(Single.just(item))); } }
@Override public Single<T> call(Single<T> upstream) { return sqlConnection.rxSetAutoCommit(false).toCompletable() .andThen(upstream) .flatMap(item -> sqlConnection.rxCommit().toCompletable().andThen(Single.just(item))) .onErrorResumeNext(throwable -> { return sqlConnection.rxRollback().toCompletable().onErrorComplete() .andThen(sqlConnection.rxSetAutoCommit(true).toCompletable().onErrorComplete()) .andThen(Single.error(throwable)); }).flatMap(item -> sqlConnection.rxSetAutoCommit(true).toCompletable().andThen(Single.just(item))); } }
protected Completable rxInsertExtraFolks(SQLConnection conn) { return conn.rxExecute(String.format(INSERT_FOLK_SQL, "Georges")).toCompletable() .andThen(conn.rxExecute(String.format(INSERT_FOLK_SQL, "Henry")).toCompletable()); }
@Override public void tearDown() throws Exception { client.rxClose().toCompletable().await(); } }
private Completable doPostJobExecutionWithoutRescheduling(Completable job, JobDetailsImpl jobDetails, Date timeSlice, Set<UUID> activeJobs) { return job .toSingle(() -> new JobExecutionState(jobDetails, activeJobs)) .flatMap(this::releaseJobExecutionLock) .flatMap(this::setJobFinished) .doOnError(t -> { logger.debug("There was an error during post-job execution, but the job has already been " + "rescheduled.", t); publishJobFinished(jobDetails); }) .doOnSuccess(states -> publishJobFinished(states.currentDetails)) .toCompletable(); }
@Override public void setUp() throws Exception { super.setUp(); client = new JDBCClient(io.vertx.ext.jdbc.JDBCClient.createNonShared(vertx, config)); client.rxGetConnection().flatMapCompletable(conn -> { Completable setup = conn.rxExecute("drop table folks if exists").toCompletable() .andThen(conn.rxExecute("create table folks (firstname varchar(255) not null)").toCompletable()); for (String name : NAMES) { setup = setup.andThen(conn.rxExecute(String.format(INSERT_FOLK_SQL, name)).toCompletable()); } return setup.doAfterTerminate(conn::close); }).await(); }