Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
EthanXQ
spring-framework
提交
6ed1b583
S
spring-framework
项目概览
EthanXQ
/
spring-framework
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6ed1b583
编写于
11月 25, 2019
作者:
R
Rossen Stoyanchev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Separate step for retrieve in RSocketRequester
Closes gh-24073
上级
b234c77b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
42 addition
and
32 deletion
+42
-32
spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketRequester.java
...g/springframework/messaging/rsocket/RSocketRequester.java
+36
-27
spring-messaging/src/main/kotlin/org/springframework/messaging/rsocket/RSocketRequesterExtensions.kt
...framework/messaging/rsocket/RSocketRequesterExtensions.kt
+3
-3
spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterTests.java
...ework/messaging/rsocket/DefaultRSocketRequesterTests.java
+3
-2
未找到文件。
spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketRequester.java
浏览文件 @
6ed1b583
...
...
@@ -238,9 +238,9 @@ public interface RSocketRequester {
}
/**
* Spec
for providing input data for an RSocket request and triggering the exchange
.
* Spec
to declare the input for an RSocket request
.
*/
interface
RequestSpec
extends
MetadataSpec
<
RequestSpec
>
{
interface
RequestSpec
extends
MetadataSpec
<
RequestSpec
>
,
RetrieveSpec
{
/**
* Append additional metadata entries through a {@code Consumer}.
...
...
@@ -262,7 +262,7 @@ public interface RSocketRequester {
* @param data the Object value for the payload data
* @return spec to declare the expected response
*/
Re
quest
Spec
data
(
Object
data
);
Re
trieve
Spec
data
(
Object
data
);
/**
* Variant of {@link #data(Object)} that also accepts a hint for the
...
...
@@ -274,7 +274,7 @@ public interface RSocketRequester {
* @param elementClass the type of values to be produced
* @return spec to declare the expected response
*/
Re
quest
Spec
data
(
Object
producer
,
Class
<?>
elementClass
);
Re
trieve
Spec
data
(
Object
producer
,
Class
<?>
elementClass
);
/**
* Variant of {@link #data(Object, Class)} for when the type hint has
...
...
@@ -285,7 +285,38 @@ public interface RSocketRequester {
* @param elementTypeRef the type of values to be produced
* @return spec to declare the expected response
*/
RequestSpec
data
(
Object
producer
,
ParameterizedTypeReference
<?>
elementTypeRef
);
RetrieveSpec
data
(
Object
producer
,
ParameterizedTypeReference
<?>
elementTypeRef
);
}
/**
* Spec for providing additional composite metadata entries.
*
* @param <S> a self reference to the spec type
*/
interface
MetadataSpec
<
S
extends
MetadataSpec
<
S
>>
{
/**
* Use this to append additional metadata entries when using composite
* metadata. An {@link IllegalArgumentException} is raised if this
* method is used when not using composite metadata.
* The metadata value be a concrete value or any producer of a single
* value that can be adapted to a {@link Publisher} via
* {@link ReactiveAdapterRegistry}.
* @param metadata an Object to be encoded with a suitable
* {@link org.springframework.core.codec.Encoder Encoder}, or a
* {@link org.springframework.core.io.buffer.DataBuffer DataBuffer}
* @param mimeType the mime type that describes the metadata
*/
S
metadata
(
Object
metadata
,
MimeType
mimeType
);
}
/**
* Spec to declare the expected output for an RSocket request.
* @since 5.2.2
*/
interface
RetrieveSpec
{
/**
* Perform a {@link RSocket#fireAndForget fireAndForget}.
...
...
@@ -330,26 +361,4 @@ public interface RSocketRequester {
<
T
>
Flux
<
T
>
retrieveFlux
(
ParameterizedTypeReference
<
T
>
dataTypeRef
);
}
/**
* Spec for specifying the metadata.
*
* @param <S> a self reference to the spec type
*/
interface
MetadataSpec
<
S
extends
MetadataSpec
<
S
>>
{
/**
* Use this to append additional metadata entries when using composite
* metadata. An {@link IllegalArgumentException} is raised if this
* method is used when not using composite metadata.
* The metadata value be a concrete value or any producer of a single
* value that can be adapted to a {@link Publisher} via
* {@link ReactiveAdapterRegistry}.
* @param metadata an Object to be encoded with a suitable
* {@link org.springframework.core.codec.Encoder Encoder}, or a
* {@link org.springframework.core.io.buffer.DataBuffer DataBuffer}
* @param mimeType the mime type that describes the metadata
*/
S
metadata
(
Object
metadata
,
MimeType
mimeType
);
}
}
spring-messaging/src/main/kotlin/org/springframework/messaging/rsocket/RSocketRequesterExtensions.kt
浏览文件 @
6ed1b583
...
...
@@ -65,7 +65,7 @@ suspend fun RSocketRequester.Builder.connectWebSocketAndAwait(uri: URI): RSocket
* @author Sebastien Deleuze
* @since 5.2
*/
inline
fun
<
reified
T
:
Any
>
RSocketRequester
.
RequestSpec
.
dataWithType
(
producer
:
Any
):
RSocketRequester
.
Re
quest
Spec
=
inline
fun
<
reified
T
:
Any
>
RSocketRequester
.
RequestSpec
.
dataWithType
(
producer
:
Any
):
RSocketRequester
.
Re
trieve
Spec
=
data
(
producer
,
object
:
ParameterizedTypeReference
<
T
>()
{})
/**
...
...
@@ -77,7 +77,7 @@ inline fun <reified T : Any> RSocketRequester.RequestSpec.dataWithType(producer:
* @author Sebastien Deleuze
* @since 5.2
*/
inline
fun
<
reified
T
:
Any
>
RSocketRequester
.
RequestSpec
.
dataWithType
(
publisher
:
Publisher
<
T
>):
RSocketRequester
.
Re
quest
Spec
=
inline
fun
<
reified
T
:
Any
>
RSocketRequester
.
RequestSpec
.
dataWithType
(
publisher
:
Publisher
<
T
>):
RSocketRequester
.
Re
trieve
Spec
=
data
(
publisher
,
object
:
ParameterizedTypeReference
<
T
>()
{})
/**
...
...
@@ -89,7 +89,7 @@ inline fun <reified T : Any> RSocketRequester.RequestSpec.dataWithType(publisher
* @author Sebastien Deleuze
* @since 5.2
*/
inline
fun
<
reified
T
:
Any
>
RSocketRequester
.
RequestSpec
.
dataWithType
(
flow
:
Flow
<
T
>):
RSocketRequester
.
Re
quest
Spec
=
inline
fun
<
reified
T
:
Any
>
RSocketRequester
.
RequestSpec
.
dataWithType
(
flow
:
Flow
<
T
>):
RSocketRequester
.
Re
trieve
Spec
=
data
(
flow
,
object
:
ParameterizedTypeReference
<
T
>()
{})
...
...
spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterTests.java
浏览文件 @
6ed1b583
...
...
@@ -40,6 +40,7 @@ import reactor.test.StepVerifier;
import
org.springframework.core.io.buffer.DefaultDataBufferFactory
;
import
org.springframework.lang.Nullable
;
import
org.springframework.messaging.rsocket.RSocketRequester.RequestSpec
;
import
org.springframework.messaging.rsocket.RSocketRequester.RetrieveSpec
;
import
org.springframework.util.MimeType
;
import
org.springframework.util.MimeTypeUtils
;
...
...
@@ -90,7 +91,7 @@ public class DefaultRSocketRequesterTests {
testSendMono
(
spec
->
spec
.
data
(
Mono
.
delay
(
MILLIS_10
).
then
(),
Void
.
class
),
""
);
}
private
void
testSendMono
(
Function
<
RequestSpec
,
Re
quest
Spec
>
mapper
,
String
expectedValue
)
{
private
void
testSendMono
(
Function
<
RequestSpec
,
Re
trieve
Spec
>
mapper
,
String
expectedValue
)
{
mapper
.
apply
(
this
.
requester
.
route
(
"toA"
)).
send
().
block
(
Duration
.
ofSeconds
(
5
));
assertThat
(
this
.
rsocket
.
getSavedMethodName
()).
isEqualTo
(
"fireAndForget"
);
...
...
@@ -114,7 +115,7 @@ public class DefaultRSocketRequesterTests {
testSendFlux
(
spec
->
spec
.
data
(
stringFlux
.
cast
(
Object
.
class
),
Object
.
class
),
values
);
}
private
void
testSendFlux
(
Function
<
RequestSpec
,
Re
quest
Spec
>
mapper
,
String
...
expectedValues
)
{
private
void
testSendFlux
(
Function
<
RequestSpec
,
Re
trieve
Spec
>
mapper
,
String
...
expectedValues
)
{
this
.
rsocket
.
reset
();
mapper
.
apply
(
this
.
requester
.
route
(
"toA"
)).
retrieveFlux
(
String
.
class
).
blockLast
(
Duration
.
ofSeconds
(
5
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录