Skip to content

Config

mongorunway.application.config ¤

VERSIONING_STARTS_FROM: typing.Final[int] = 1 module-attribute ¤

__all__: typing.Sequence[str] = ('FileSystemConfig', 'Config', 'ApplicationConfig', 'VERSIONING_STARTS_FROM') module-attribute ¤

ApplicationConfig ¤

Source code in mongorunway\application\config.py
@attr.define(frozen=True, kw_only=True, repr=True, eq=True)
class ApplicationConfig:
    app_client: mongo.Client = attr.field(repr=False)
    app_database: mongo.Database = attr.field(repr=False)
    app_repository: repository_port.MigrationModelRepository = attr.field(repr=False)
    app_auditlog_journal: typing.Optional[auditlog_journal_port.AuditlogJournal] = attr.field(
        repr=False,
    )
    app_name: str = attr.field(
        validator=[attr.validators.min_len(1), attr.validators.instance_of(str)],  # type: ignore[arg-type]
        repr=True,
        eq=True,
    )
    app_timezone: str = attr.field(
        validator=attr.validators.instance_of(str),
        default="UTC",
        repr=True,
    )
    app_date_format: str = attr.field(
        default="%Y-%m-%d %H:%M:%S",
        validator=attr.validators.instance_of(str),
    )
    app_events: typing.Mapping[
        typing.Type[domain_event.MigrationEvent],
        typing.Sequence[domain_event.EventHandlerProxyOr[domain_event.EventHandler]],
    ] = attr.field(factory=dict, repr=False)
    app_auditlog_limit: typing.Optional[int] = attr.field(
        default=None,
        validator=attr.validators.optional(attr.validators.instance_of(int)),
        converter=attr.converters.optional(int),
        repr=False,
    )

    use_logging: bool = attr.field(default=True, repr=False, converter=attr.converters.to_bool)
    use_auditlog: bool = attr.field(default=False, repr=False, converter=attr.converters.to_bool)
    use_indexing: bool = attr.field(default=False, converter=attr.converters.to_bool, repr=False)
    use_schema_validation: bool = attr.field(
        default=True,
        converter=attr.converters.to_bool,
        repr=False,
    )
    raise_on_transaction_failure: bool = attr.field(
        default=True, converter=attr.converters.to_bool, repr=False
    )

    @property
    def is_auditlog_enabled(self) -> bool:
        return self.app_auditlog_journal is not None and self.use_auditlog

    @property
    def is_logged(self) -> bool:
        return self.use_logging

    @property
    def has_unique_timezone(self) -> bool:
        return self.app_timezone != "UTC"

app_auditlog_journal: typing.Optional[auditlog_journal_port.AuditlogJournal] = attr.field(repr=False) instance-attribute class-attribute ¤

app_auditlog_limit: typing.Optional[int] = attr.field(default=None, validator=attr.validators.optional(attr.validators.instance_of(int)), converter=attr.converters.optional(int), repr=False) instance-attribute class-attribute ¤

app_client: mongo.Client = attr.field(repr=False) instance-attribute class-attribute ¤

app_database: mongo.Database = attr.field(repr=False) instance-attribute class-attribute ¤

app_date_format: str = attr.field(default='%Y-%m-%d %H:%M:%S', validator=attr.validators.instance_of(str)) instance-attribute class-attribute ¤

app_events: typing.Mapping[typing.Type[domain_event.MigrationEvent], typing.Sequence[domain_event.EventHandlerProxyOr[domain_event.EventHandler]]] = attr.field(factory=dict, repr=False) instance-attribute class-attribute ¤

app_name: str = attr.field(validator=[attr.validators.min_len(1), attr.validators.instance_of(str)], repr=True, eq=True) instance-attribute class-attribute ¤

app_repository: repository_port.MigrationModelRepository = attr.field(repr=False) instance-attribute class-attribute ¤

app_timezone: str = attr.field(validator=attr.validators.instance_of(str), default='UTC', repr=True) instance-attribute class-attribute ¤

has_unique_timezone: bool property ¤

is_auditlog_enabled: bool property ¤

is_logged: bool property ¤

raise_on_transaction_failure: bool = attr.field(default=True, converter=attr.converters.to_bool, repr=False) instance-attribute class-attribute ¤

use_auditlog: bool = attr.field(default=False, repr=False, converter=attr.converters.to_bool) instance-attribute class-attribute ¤

use_indexing: bool = attr.field(default=False, converter=attr.converters.to_bool, repr=False) instance-attribute class-attribute ¤

use_logging: bool = attr.field(default=True, repr=False, converter=attr.converters.to_bool) instance-attribute class-attribute ¤

use_schema_validation: bool = attr.field(default=True, converter=attr.converters.to_bool, repr=False) instance-attribute class-attribute ¤

Config ¤

Source code in mongorunway\application\config.py
@attr.define(frozen=True, kw_only=True, repr=True)
class Config:
    filesystem: FileSystemConfig = attr.field(repr=True)
    application: ApplicationConfig = attr.field(repr=True)
    logging_dict: typing.Dict[str, typing.Any]

application: ApplicationConfig = attr.field(repr=True) instance-attribute class-attribute ¤

filesystem: FileSystemConfig = attr.field(repr=True) instance-attribute class-attribute ¤

logging_dict: typing.Dict[str, typing.Any] instance-attribute ¤

FileSystemConfig ¤

Source code in mongorunway\application\config.py
@attr.define(frozen=True, kw_only=True, repr=True)
class FileSystemConfig:
    scripts_dir: str = attr.field(repr=True, validator=attr.validators.instance_of(str))
    config_dir: str = attr.field(repr=False, validator=attr.validators.instance_of(str))
    filename_strategy: filename_strategy_port.FilenameStrategy = attr.field(repr=True)
    use_filename_strategy: bool = attr.field(
        default=True,
        converter=attr.converters.to_bool,
        repr=True,
    )

config_dir: str = attr.field(repr=False, validator=attr.validators.instance_of(str)) instance-attribute class-attribute ¤

filename_strategy: filename_strategy_port.FilenameStrategy = attr.field(repr=True) instance-attribute class-attribute ¤

scripts_dir: str = attr.field(repr=True, validator=attr.validators.instance_of(str)) instance-attribute class-attribute ¤

use_filename_strategy: bool = attr.field(default=True, converter=attr.converters.to_bool, repr=True) instance-attribute class-attribute ¤