Is the facade design pattern only concerned with classes/modules or actual API calls too?

房东的猫 提交于 2021-01-28 14:00:51

问题


I think I understand the purpose of the facade design pattern- to provide an interface to a client that simplifies and abstracts a complex system allowing them to more easily perform a specific task.

but the first thing I think of is a microservices style system that has many apis with each having a specific purpose and functionality.

If I create another API (microservice) that makes calls on behalf of the client to a couple of the other APIs and abstracts the multiple APIs calls to just one call, simplifying the APIs' specific usage away to make it easier for the client to do something, is that a facade too?

Or maybe a facade would not make APIs call but import the modules used by the other APIs to get their functionality?

I want to know if "facade" is the correct pattern here or if there is a more specific pattern for abstracting multiple REST API calls in a complex system.


回答1:


Yes there is,

API Gateway / Backends for Frontends

API gateway that is the single entry point for all clients. The API gateway handles requests in one of two ways. Some requests are simply proxied/routed to the appropriate service. It handles other requests by fanning out to multiple services.

A variation of this pattern is the Backends for frontends pattern. It defines a separate API gateway for each kind of client.




回答2:


Thoughtworks has recommended GraphQL for server-side resource aggregation as one pattern for abstracting multiple REST API calls. It fits into the BFF pattern mentioned in the accepted answer.



来源:https://stackoverflow.com/questions/61870915/is-the-facade-design-pattern-only-concerned-with-classes-modules-or-actual-api-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!