-1

I'm trying to implement a simple circuit breaker where I have a local file system and remote database.

All good with changing to half-open state when the remote database goes down. I'm trying to find a way to move from half-open to closed state when the remote database is available.

Its become a huge pain to sync all the data in local file system with the remote database. I'm starting to believe that changes to data shouldn't be allowed with the circuit breaker is not closed.

When not in closed state of circuit breaker, should my application be a readonly system?

Neeraj Krishna
  • 1,527
  • 2
  • 16
  • 22

1 Answers1

2

Typically a circuit breaker implementation would periodically "try" the real operation when in half-open state, and make the decision based on the result. For example, it can select to execute 1 out of every 100 requests, or 1 request every 10 seconds, etc.

But i think what you are really asking is what your app should do while the circuit-breaker is in "non-closed" state. I think that would depend on the application and should be considered outside of "circuit-breaker" scope. For example if your app just stores some historical records into the db, it may be perfectly fine to store them into the local file-system and then insert them to the db later on (like you seem to be doing). But for many apps the only option would probably be to "fail/reject" the operations when the db is not available. A circuit breaker in this case would help to fail-fast, without actually performing the db operation (and having to timeout for example).

murtiko
  • 253
  • 1
  • 3
  • 14