Circuit breaker is a design pattern that 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.
You can define it for a specific route too. In the following example GET /users cannot be called more than 4 times every second.
Circuit Breaker State Management
Circuit Breaker requires failures to be stored somewhere - the options available currently are in-memory and Redis. For production, you should always be using Redis for storing state. In-memory state exists primarily for development workflows. The default is in-memory state.
To store state in redis:
To store the state in memory, can leave the 'state' field undefined. However, if you want to be more explicit about it: