from enum import Enum
from typing import Optional


class StoreStrategy(Enum):
    IN_MEMORY = "IN_MEMORY"
    REDIS = "REDIS"


class RedisConfig(object):
    def __init__(
        self,
        host: str,
        port: int,
        db: int,
        ssl: bool,
    ):
        self.host = host
        self.port = port
        self.db = db
        self.ssl = ssl


class Configuration(object):
    def __init__(
        self,
        store_strategy: StoreStrategy,
        registration_expiration: float,
        redis_config: Optional[RedisConfig] = None,
    ):
        if store_strategy == StoreStrategy.REDIS and redis_config is None:
            raise RuntimeError("When using Redis the Redis configuration must be sent")

        self.store_strategy = store_strategy
        self.registration_expiration = registration_expiration
        self.redis_config = redis_config
