Skip to content
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

cleanup+redis cache config error #1

Merged
merged 3 commits into from
May 12, 2022
Merged

cleanup+redis cache config error #1

merged 3 commits into from
May 12, 2022

Conversation

burdettadam
Copy link
Collaborator

cleaned up some code and added an error for failed configurations and cache key-value setting.

Signed-off-by: Adam Burdett <burdettadam@gmail.com>
Signed-off-by: Adam Burdett <burdettadam@gmail.com>
Signed-off-by: Adam Burdett <burdettadam@gmail.com>

raise RedisCacheConfigurationError(
"Configuration missing for redis queue"
) from error
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of the problem with combining all of these is that it makes username/passwords/SSL required configuration options. Most people when using redis just end up using the default user with no password and they don't bother setting up SSL. This would have been the case had I done my development with containers, but using my own redis server presented the complications of more strict security settings. The only config option that was required here was config["connection"]. All other options {credentials:{username,password}, ssl:{cacerts}} are (and should be) optional.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aww! I understand the catch and pass now. there is an unused ssl.context hanging around, I assumed there was more at hand than I saw. I agree with you on the optional configs.

# self._cache[key] = {"expires": expires_ts, "value": value}
await self.redis.set(f"ACA-Py:{key}", json.dumps(value), ex=ttl)
except aioredis.RedisError as error:
raise RedisCacheSetKeyValueError("Unexpected redis client exception") from error
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea! Should there be one for the GET command as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not sure if not getting something would be an error. maybe a connection to Redis died and we could wrap that error with a get. Not sure. I think I am in favor of another error type for 'get'.

@TheTechmage TheTechmage merged commit aa19fd8 into main May 12, 2022
@TheTechmage TheTechmage deleted the feature/cleanup branch June 8, 2022 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants