Feature Request: Add `Observable.usingWhen()` for resources generated by a `Publisher`
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 30/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- java
调研方向
首先检查现有的 Single.using() 行为,并将其与 Reactor 的 Mono.usingWhen() 语义进行比较。定义 Observable.usingWhen() 在成功、错误、终止和处置时的清理行为,然后为这些情况添加覆盖。完成标准是原生支持由 Publisher 创建的资源及其清理。
由索引模型根据 Issue 内容生成。
描述
Version: 3.1.6
In Reactor, there is Mono.usingWhen(), which works similarly to Mono.using(), but supports resources that are generated and cleaned up with a Publisher.
For example, here's a use case in r2dbc-pool:
Mono<Object> result = Mono.usingWhen(
connectionFactory.create(), // Publisher<Connection>
connection -> executeQuery(connection),
Connection::close // Publisher<Void>
);
In RxJava, we have Single.using(), which works the same way as Mono.using(), so there's no support for reactive resource generation/cleanup. I was thinking of doing something like this:
Single<Object> result = Single
.fromPublisher(connectionFactory.create())
.flatMap(connection -> executeQuery(connection)
.flatMap(result -> Completable
.fromPublisher(connection.close())
.toSingleDefault(result)));
However, this does not handle cases like connection cleanup on error, dispose or terminate. The .doOnXyz() methods would not suffice, so I'm guessing this would require a custom Observable implementation, unless I'm missing something obvious. I've also checked RxJavaExtensions for anything similar to what I'm trying to achieve, but I was not able to find anything, nor could I find anything relevant on Stack Overflow.
I currently have the option of just using Mono.usingWhen() and then convert it to a Single, but it would be nice to have this natively available in RxJava. Would you be willing to add support for usingWhen()?
- 主要语言
- Java
- 星标
- 48.2k
- 派生
- 7.6k
- 平均合并
- 3 小时 2 分钟
- 30 天内合并 PR
- 27
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ReactiveX/RxJava 的其他 Issue
-
4.x Streamable Test-Failures
难度 4/5 3-5 天 新手友好度 45/100
维护者通常 1 天内回复
-
4.x AI Enhancement Streamable
难度 4/5 3-5 天 新手友好度 45/100
ReactiveX/RxJava#8299 · 1 条评论 ·
维护者通常 1 天内回复
-
4.x: FlowableBufferTest > longTimeAction() FAILED可能重新可做 @akarnokd 于 81 天前认领,目前没有进行中的 PR。 未关闭4.x Test-Failures
ReactiveX/RxJava#8280 · 已指派 1 人 ·
维护者通常 1 天内回复
-
4.x Discussion
难度 5/5 一周以上 新手友好度 25/100
维护者通常 1 天内回复
-
4.x PR welcome Test Test-Failures
难度 4/5 3-5 天 新手友好度 45/100
ReactiveX/RxJava#8075 · 4 条评论 ·
维护者通常 1 天内回复
相似的 Issue
-
[BUG] micronaut-serde-oracle-jdbc-json brings a second OJDBC driver onto the runtime classpath可能已有人在做 @ZARAYACH 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
micronaut-projects/micronaut-serialization#1494 · 4 条评论 ·
维护者通常 2 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 73/100
维护者通常 2 天内回复
-
code-health feature/sync OS/Android QA/Test-Plan-Specified QA/Yes
难度 2/5 1-3 小时 新手友好度 75/100
brave/brave-browser#60327 ·
维护者通常 1 天内回复
-
Type: Bug
难度 2/5 1-3 小时 新手友好度 65/100
it-at-m/raumreservierung#383 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
aws/context-ontology-accelerator#325 ·
维护者通常 1 天内回复