Skip to content

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

@Ankcorn

Description

@Ankcorn

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions