Last active
July 31, 2020 09:16
-
-
Save vietj/b8b609bf5227e7ae0ff21f05be56c993 to your computer and use it in GitHub Desktop.
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 Single<List<String>> inTransaction(Exception e) throws Exception { | |
return client.rxGetConnection().flatMap(conn -> { | |
return rxInsertExtraFolks(conn) | |
.andThen(uniqueNames(conn)) | |
.<List<String>>collect(ArrayList::new, List::add) | |
.compose(upstream -> e == null ? upstream : upstream.flatMap(names -> Single.error(e))) | |
.compose(SQLClientHelper.txSingleTransformer(conn)) | |
.flatMap(names -> rxAssertAutoCommit(conn).andThen(Single.just(names))) | |
.doFinally(conn::close); | |
}); | |
} | |
private Single<List<String>> withTransaction(Exception e) { | |
return client.rxWithTransaction((Function<SqlClient, Single<List<String>>>) sqlClient -> | |
rxInsertExtraFolks(sqlClient) | |
.flatMapPublisher(res -> uniqueNames(sqlClient)) | |
.<List<String>>collect(ArrayList::new, List::add) | |
.compose(upstream -> e == null ? upstream : upstream.flatMap(names -> Single.error(e)))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment