-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What are some use cases of this project? #47
Comments
@kfcaio Hi there! I think it's worth using when you want to store some key/values in memory, but working with same operations expected from any cache database (get, set, delete, increment, expire..) in an abstracted and simple manner. I work at Luizalabs and in our squad, we use it in one of our applications as a circuit breaker (we are using lasier as a circuit breaker library) state control database (e,g: threshold for when we open, errors count per service and other parameters) for some services we request. Before that, our application used a common shared circuit breaker (actually, a Redis server) among all our app instances, generating too many requests (network calls). Since it wouldn't have a significant business impact (of course it's not the ideal) whether we had some inconsistency (e.g: our application has two instances running, but one of them is with an open circuit breaker and the other one no). We could reduce significantly network calls and hence, improve application's instance. (By the way, it is uncommon to find inconsistencies among app instances). Below, there's a code how we use it using aiocache: AIO_CACHES = {
'redis': {
# Redis configs here
}
'circuit_breaker': {
'cache': 'shared_memory_dict.caches.aiocache.SharedMemoryCache',
'size': 1024,
'name': 'circuit_breaker'
}
} So when we need to pass it on to the circuit breaker code implementation, it works like a cache implementation, since implements all operations (get, set, increment etc) that's needed for the circuit breaker to handle its state. @circuit_breaker(
rule=rule,
cache=cache,
failure_exception=OpenCircuitException,
catch_exceptions=(CustomServiceException, )
)
async service_call(
id
):
try:
network_call(id)
except CustomServiceException:
pass It's also worth to mention you could use it when your application needs to share state among processes using a key/value abstraction. For example, our application starts creating with some gunicorn processes, so the state exemplified above is shared among all of them. Does it make sense? |
I missed some details in the README file regarding common use cases of this project. It would be nice if luizalabs explains how she is using it in prod right now in order to get more eyes looking at it.
The text was updated successfully, but these errors were encountered: