Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加ISprotoRequest<TProtocol,TResponse>接口标记 #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

增加ISprotoRequest<TProtocol,TResponse>接口标记 #9

wants to merge 1 commit into from

Conversation

watercoldyi
Copy link

每个rpc的request类型都会实现该接口,标记出自己所属的protocol以及response,这有助于上层客户端实现时利用编译器自动推导出请求的response与protocol,而不必每次需要指定三个类型。

例如有一个这样的sproto协议:

foobar 1 {
       request {}
       response {}
}

上层客户端通常会封装一个这样的接口:

Task<TResponse> Call<TProtocol,TResponse>(SprotoTypeBase req);

调用是这样的:

var req = new foobar.request();
client.Call<Protocol.foobar,foobar.response>(req);

利用ISprotoRequest接口标记后,只需要这样写:

var req = new foobar.request();
client.Call(req);

让编译器去推断协议类型以及回应类型

每个rpc的request类型都会实现该接口,标记出自己所属的protocol以及response,这有助于上层客户端实现时利用编译器自动推导出请求的response与protocol,而不必每次需要指定三个类型。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant