[英]At what level should i integrate two services (client vs server)
I have a service Stock/Products(REST API) and a service Orders (RPC API). 我有一个服务库存/产品(REST API)和一个服务订单(RPC API)。 The Orders service will use some data from Stock/Products. 订单服务将使用库存/产品中的某些数据。
Orders will be used from a GUI Client. 订单将从GUI客户端使用。
I see two options for integrating: 我看到两个集成选项:
Which would be a better approach? 哪种方法更好? I tend to choose (2) because i don't see why I would 'tunnel' the REST API through the RPC API. 我倾向于选择(2),因为我不明白为什么我会通过RPC API“隧道化” REST API。
I think you should prefer integration in the server, because encapsulation is better that way. 我认为您应该更喜欢服务器中的集成,因为这样封装更好。 Your chief objective should be to make life as easy for clients as possible. 您的主要目标应该是使客户的生活尽可能轻松。
The client should only need to know that they want their orders. 客户只需要知道他们想要他们的订单即可。 Let the server handle the details of assembling products. 让服务器处理组装产品的细节。
You have a perfect example in Amazon.com. 您在Amazon.com上拥有一个完美的例子。 They let you get what you need with a single request, but lots of services participate in making it so. 他们让您仅需一个请求就可以满足您的需求,但是很多服务都参与其中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.