Snawoot / postfix-mta-sts-resolver

Daemon which provides TLS client policy for Postfix via socketmap, according to domain MTA-STS policy
MIT License
117 stars 23 forks source link

Support for redis sentinel #94

Closed acteru closed 1 year ago

acteru commented 1 year ago

Is your feature request related to a problem? Please describe. We would like to be able to connect to Redis sentinel cluster that we are already have in place for rspamd. But it looks like this is currently not implemented/supported. (Please correct me if I am wrong).

Describe the solution you'd like The option to discover the current (r/w) master instance of Redis. It looks like this is possible using the library already in use. https://aioredis.readthedocs.io/en/latest/api/high-level/#aioredis.client maybe implemented via an alternative connection string.

Describe alternatives you've considered At the moment, we can absolutely live with a single redis instance or sqlite for the cache, but still would be nice to have this.

Additional context thanks for this project and your work!

Snawoot commented 1 year ago

Hello!

Thanks! I think implementation should be straightforward. You can just copy class RedisCache in redis_cache.py to something like RedisSentinelCache in the same file and modify it to accept another set of options in the constructor, construct sentinel client instead of regular redis client and use current master for all database operations. Then you can add new kind of cache (like redis_sentinel) in the virtual constructor of cache. Finally, you'll be able to specify new kind of cache in the daemon config and pass all necessary options to instantiate it (list of redis nodes, ...).

Once that will work out for you, don't hesitate to send pull request -- it will be very welcome!