断路器 微服务
NOTE: This article is for people that have basic understanding about Microservices Architecture (MSA) and want to deep dive into it. If you are newbie in MSA world, I would like to recommend 2 websites — where you can find everything related to MSA from beginner to advanced level:
注意:本文适用于对微服务体系结构(MSA)有基本了解并希望深入研究它的人们。 如果您是MSA领域的新手,我想推荐2个网站-从初级到高级,您都可以找到与MSA相关的所有信息:
https://martinfowler.com/microservices/
什么是断路器? (What is Circuit Breaker?)
A circuit breaker is an automatically operated electrical switch designed to protect an electrical circuit from damage caused by excess current from an overload or short circuit. Its basic function is to interrupt current flow after a fault is detected. Unlike a fuse, which operates once and then must be replaced, a circuit breaker can be reset (either manually or automatically) to resume normal operation. — Wikipedia.
背景 技术断路器 是自动操作的 电 切换 设计用来保护一个 电路 从过载或过剩引起的电流损坏 短路 。 它的基本功能是在检测到故障后中断电流。 与 只能操作一次然后必须更换 的 保险丝 不同 ,可以将断路器复位(手动或自动)以恢复正常操作。 — 维基百科 。
But, wait….!
可是等等…。!
This is a Software Programming topic, and why I’m bring something related to Electrical Technology into this topic?
这是一个软件编程主题,为什么我将与电气技术相关的东西带入该主题?
Because the way we apply Circuit Breaker Pattern in Software Programming is very similar. And I just want to bring something that you are familiar with in order to make the topic easier to understand.
因为我们在软件编程中应用断路器模式的方式非常相似。 我只想带一些您熟悉的东西,以使该主题更易于理解。
Back to the definition of Circuit Breaker in Software Programming…
返回软件编程中断路器的定义…
Circuit Breaker pattern is used to detect failures and encapsulates the logic of preventing a failure from constantly recurring, during maintenance, temporary external system failure or unexpected system difficulties. — Wikipedia
断路器模式用于检测故障,并封装了防止故障在维护期间不断重复发生,维护,临时外部系统故障或意外系统故障的逻辑。 — 维基百科
Bear in mind that, It’s not available to prevent the broken service, but not to make it worse than it was. While other design patterns are born for making our solution easy to maintain, maximize reusability, better performance… then Circuit Breaker is the one for “when sh*t happens”.
请记住,它不能用于防止服务中断,但不能使其比以前更糟。 虽然其他设计模式应运而生,以使我们的解决方案易于维护,最大化可重用性,更好的性能……然后断路器是“ 当