database - 使用数据库包装微服务是一种反模式吗?

标签 database microservices anti-patterns

假设我有一个封装数据库的微服务,该服务的整个功能将数据库的详细信息隐藏在通用(例如 REST)API 后面,从而允许更改数据库而不影响其他服务。

这是一种反模式吗? 这种方法的优点/缺点是什么?

最佳答案

是的,这是一种反模式。

Building Micro Services 2nd page 03 中所述

If you see a microservice that just looks like a thin wrapper around database CRUD operations, that is a sign that you may have weak cohesion and tighter coupling, as logic that should be in that service to manage the data is instead spread elsewhere in your system.

它也被称为“上帝服务”反模式

God Service Anti-PatternDesigning Event-Driven Systems page 81中所述

Now creating something that looks like a kooky, shared database can lead to a set of issues of its own. The more functionality, data, and users data services have, the more tightly coupled they become and the harder (and more expensive) they are to operate and evolve.

Encapsulation aka information hiding是一种著名的软件设计模式。您应该将逻辑封装在一项服务中,而不是暴露整个数据库。

关于database - 使用数据库包装微服务是一种反模式吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53266565/

相关文章:

php - 回显 $image,其中用户名是 $name

c# - 如何防止箭头反模式

mysql - if语句,修改输出

sql - 如何在sql数据库中所有表的所有列中搜索和替换字符串的一部分

ruby-on-rails - 为什么拥有数据库密码很重要? (例如,在 Rails 中)

spring-boot - netflix zuul服务器和netflix Eureka 服务器有什么区别?

architecture - 单个数据库与多个数据库 - 微服务架构

microservices - 需要澄清微服务

anti-patterns - 您在生产企业环境中见过的最邪恶的代码是什么?

java - GWT 客户端工厂 : Isn't this just a big blob/monolith?