Improved database module structure

This commit is contained in:
Sven Heidemann 2020-12-06 21:14:57 +01:00
parent 8551a0b7b7
commit 6977b9ae05
9 changed files with 10 additions and 23 deletions

View File

@ -5,8 +5,8 @@ from sh_edraft.configuration.base.configuration_base import ConfigurationBase
from sh_edraft.hosting.base.application_runtime_base import ApplicationRuntimeBase
from sh_edraft.hosting.application_runtime import ApplicationRuntime
from sh_edraft.hosting.base.application_host_base import ApplicationHostBase
from sh_edraft.service.providing.service_provider import ServiceProvider
from sh_edraft.service.providing.base.service_provider_base import ServiceProviderBase
from sh_edraft.service.service_provider import ServiceProvider
from sh_edraft.service.base.service_provider_base import ServiceProviderBase
class ApplicationHost(ApplicationHostBase):

View File

@ -2,7 +2,7 @@ from abc import ABC, abstractmethod
from sh_edraft.configuration.base.configuration_base import ConfigurationBase
from sh_edraft.hosting.base.application_runtime_base import ApplicationRuntimeBase
from sh_edraft.service.providing.base.service_provider_base import ServiceProviderBase
from sh_edraft.service.base.service_provider_base import ServiceProviderBase
class ApplicationHostBase(ABC):

View File

@ -54,7 +54,7 @@ class Logger(LoggerBase):
# open log file, create if not exists
path = f'{self._path}{self._log}'
f = open(path, "w+")
Console.write_line(f'[{__name__}]: Using log file: {path}', 'green')
Console.write_line(f'[{__name__}]: Using log file: {path}')
f.close()
except Exception as e:
self._fatal_console(__name__, 'Cannot open log file', ex=e)

View File

@ -20,6 +20,7 @@ __version__ = '2020.12.5'
from collections import namedtuple
# imports:
from .service_provider import ServiceProvider
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=5)

View File

@ -21,6 +21,7 @@ from collections import namedtuple
# imports:
from .service_base import ServiceBase
from .service_provider_base import ServiceProviderBase
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=5)

View File

@ -20,6 +20,7 @@ __version__ = '2020.12.5'
from collections import namedtuple
# imports:
from .provide_state import ProvideState
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=5)

View File

@ -21,7 +21,6 @@ from collections import namedtuple
# imports:
from .console import Console
from .credential_manager import CredentialManager
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=5)

View File

@ -4,11 +4,5 @@
"Filename": "log_$start_time.log",
"ConsoleLogLevel": "TRACE",
"FileLogLevel": "TRACE"
},
"DatabaseSettings": {
"ConnectionString": "mysql+mysqlconnector://sh_messenger_server:$credentials@localhost/sh_messenger_server",
"Credentials": "ZkM1U1dyU0hXM3oyI3BfXg==",
"Encoding": "utf8mb4"
}
}

View File

@ -1,13 +1,11 @@
from typing import Optional
from sh_edraft.configuration.base import ConfigurationBase
from sh_edraft.database import DatabaseConnection
from sh_edraft.database.base import DatabaseConnectionBase
from sh_edraft.hosting import ApplicationHost
from sh_edraft.hosting.base import ApplicationBase
from sh_edraft.logging import Logger
from sh_edraft.logging.base import LoggerBase
from sh_edraft.service.providing.base import ServiceProviderBase
from sh_edraft.service.base import ServiceProviderBase
class Program(ApplicationBase):
@ -19,7 +17,6 @@ class Program(ApplicationBase):
self._services: Optional[ServiceProviderBase] = None
self._configuration: Optional[ConfigurationBase] = None
self._logger: Optional[LoggerBase] = None
self._db_connection: Optional[DatabaseConnectionBase] = None
def create_application_host(self):
self._app_host = ApplicationHost()
@ -33,19 +30,13 @@ class Program(ApplicationBase):
self._configuration.add_argument_variables()
self._configuration.add_json_file(f'appsettings.json')
self._configuration.add_json_file(f'appsettings.{self._configuration.environment.environment_name}.json')
self._configuration.add_json_file(
f'appsettings.{self._configuration.environment.host_name}.json',
optional=True
)
self._configuration.add_json_file(f'appsettings.{self._configuration.environment.host_name}.json', optional=True)
def create_services(self):
self._services.create()
self._services.add_singleton(LoggerBase, Logger)
self._services.add_singleton(DatabaseConnectionBase, DatabaseConnection)
self._logger: Logger = self._services.get_service(LoggerBase)
self._logger = self._services.get_service(LoggerBase)
self._logger.create()
self._db_connection: DatabaseConnection = self._services.get_service(DatabaseConnectionBase)
self._db_connection.create()
def main(self):
self._logger.header(f'{self._configuration.environment.application_name}:')