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

Avoid creating many redis connections when you want to have seperate buckets of templates. #94

Open
Ankcorn opened this issue Feb 16, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@Ankcorn
Copy link

Ankcorn commented Feb 16, 2024

Currently when using drain3 with redis you have to configure a redis_key. This key can be a useful way to seperate data and make Drain3 useful in a multi tenant situation where you might not want templates to be shared.

i.e. Setting up the template miner with redis persistence.

 persistance = RedisPersistence(
            redis_host=self.redis_config.redis_host,
            redis_port=self.redis_config.redis_port,
            redis_db=self.redis_config.redis_db,
            redis_pass=self.redis_config.redis_pass,
            is_ssl=self.redis_config.is_ssl,
            redis_key=self.get_key(workspace, environment)
        )
 template_miner = TemplateMiner(persistance, config=self.config)

This code creates a redis connection when you instantiate RedisPersistance, this means that with many tenants you can have issues with too many connections.

It would be desirable for RedisPersistance to take an optional property of redis.Redis so that multiple connections are not made.

i.e. Create Redis connection and pass it in to RedisPersistence

import redis

redis_connection = redis.Redis(...)


 persistance = RedisPersistence(
            redis= redis_connection
            redis_key=self.get_key(workspace, environment)
        )
 template_miner = TemplateMiner(persistance, config=self.config)
@Superskyyy
Copy link
Collaborator

Hi, thanks for the issue, would you like to open a pull request?

@Superskyyy Superskyyy added the enhancement New feature or request label Feb 19, 2024
@Ankcorn
Copy link
Author

Ankcorn commented Feb 26, 2024

Hi, yes I will make a PR 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants