Improved database module structure
This commit is contained in:
parent
8551a0b7b7
commit
6977b9ae05
@ -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.base.application_runtime_base import ApplicationRuntimeBase
|
||||||
from sh_edraft.hosting.application_runtime import ApplicationRuntime
|
from sh_edraft.hosting.application_runtime import ApplicationRuntime
|
||||||
from sh_edraft.hosting.base.application_host_base import ApplicationHostBase
|
from sh_edraft.hosting.base.application_host_base import ApplicationHostBase
|
||||||
from sh_edraft.service.providing.service_provider import ServiceProvider
|
from sh_edraft.service.service_provider import ServiceProvider
|
||||||
from sh_edraft.service.providing.base.service_provider_base import ServiceProviderBase
|
from sh_edraft.service.base.service_provider_base import ServiceProviderBase
|
||||||
|
|
||||||
|
|
||||||
class ApplicationHost(ApplicationHostBase):
|
class ApplicationHost(ApplicationHostBase):
|
||||||
|
@ -2,7 +2,7 @@ from abc import ABC, abstractmethod
|
|||||||
|
|
||||||
from sh_edraft.configuration.base.configuration_base import ConfigurationBase
|
from sh_edraft.configuration.base.configuration_base import ConfigurationBase
|
||||||
from sh_edraft.hosting.base.application_runtime_base import ApplicationRuntimeBase
|
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):
|
class ApplicationHostBase(ABC):
|
||||||
|
@ -54,7 +54,7 @@ class Logger(LoggerBase):
|
|||||||
# open log file, create if not exists
|
# open log file, create if not exists
|
||||||
path = f'{self._path}{self._log}'
|
path = f'{self._path}{self._log}'
|
||||||
f = open(path, "w+")
|
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()
|
f.close()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._fatal_console(__name__, 'Cannot open log file', ex=e)
|
self._fatal_console(__name__, 'Cannot open log file', ex=e)
|
||||||
|
@ -20,6 +20,7 @@ __version__ = '2020.12.5'
|
|||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
# imports:
|
# imports:
|
||||||
|
from .service_provider import ServiceProvider
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major=2020, minor=12, micro=5)
|
version_info = VersionInfo(major=2020, minor=12, micro=5)
|
||||||
|
@ -21,6 +21,7 @@ from collections import namedtuple
|
|||||||
|
|
||||||
# imports:
|
# imports:
|
||||||
from .service_base import ServiceBase
|
from .service_base import ServiceBase
|
||||||
|
from .service_provider_base import ServiceProviderBase
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major=2020, minor=12, micro=5)
|
version_info = VersionInfo(major=2020, minor=12, micro=5)
|
||||||
|
@ -20,6 +20,7 @@ __version__ = '2020.12.5'
|
|||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
# imports:
|
# imports:
|
||||||
|
from .provide_state import ProvideState
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major=2020, minor=12, micro=5)
|
version_info = VersionInfo(major=2020, minor=12, micro=5)
|
||||||
|
@ -21,7 +21,6 @@ from collections import namedtuple
|
|||||||
|
|
||||||
# imports:
|
# imports:
|
||||||
from .console import Console
|
from .console import Console
|
||||||
from .credential_manager import CredentialManager
|
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major=2020, minor=12, micro=5)
|
version_info = VersionInfo(major=2020, minor=12, micro=5)
|
||||||
|
@ -4,11 +4,5 @@
|
|||||||
"Filename": "log_$start_time.log",
|
"Filename": "log_$start_time.log",
|
||||||
"ConsoleLogLevel": "TRACE",
|
"ConsoleLogLevel": "TRACE",
|
||||||
"FileLogLevel": "TRACE"
|
"FileLogLevel": "TRACE"
|
||||||
},
|
|
||||||
|
|
||||||
"DatabaseSettings": {
|
|
||||||
"ConnectionString": "mysql+mysqlconnector://sh_messenger_server:$credentials@localhost/sh_messenger_server",
|
|
||||||
"Credentials": "ZkM1U1dyU0hXM3oyI3BfXg==",
|
|
||||||
"Encoding": "utf8mb4"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,13 +1,11 @@
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from sh_edraft.configuration.base import ConfigurationBase
|
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 import ApplicationHost
|
||||||
from sh_edraft.hosting.base import ApplicationBase
|
from sh_edraft.hosting.base import ApplicationBase
|
||||||
from sh_edraft.logging import Logger
|
from sh_edraft.logging import Logger
|
||||||
from sh_edraft.logging.base import LoggerBase
|
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):
|
class Program(ApplicationBase):
|
||||||
@ -19,7 +17,6 @@ class Program(ApplicationBase):
|
|||||||
self._services: Optional[ServiceProviderBase] = None
|
self._services: Optional[ServiceProviderBase] = None
|
||||||
self._configuration: Optional[ConfigurationBase] = None
|
self._configuration: Optional[ConfigurationBase] = None
|
||||||
self._logger: Optional[LoggerBase] = None
|
self._logger: Optional[LoggerBase] = None
|
||||||
self._db_connection: Optional[DatabaseConnectionBase] = None
|
|
||||||
|
|
||||||
def create_application_host(self):
|
def create_application_host(self):
|
||||||
self._app_host = ApplicationHost()
|
self._app_host = ApplicationHost()
|
||||||
@ -33,19 +30,13 @@ class Program(ApplicationBase):
|
|||||||
self._configuration.add_argument_variables()
|
self._configuration.add_argument_variables()
|
||||||
self._configuration.add_json_file(f'appsettings.json')
|
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.environment_name}.json')
|
||||||
self._configuration.add_json_file(
|
self._configuration.add_json_file(f'appsettings.{self._configuration.environment.host_name}.json', optional=True)
|
||||||
f'appsettings.{self._configuration.environment.host_name}.json',
|
|
||||||
optional=True
|
|
||||||
)
|
|
||||||
|
|
||||||
def create_services(self):
|
def create_services(self):
|
||||||
self._services.create()
|
self._services.create()
|
||||||
self._services.add_singleton(LoggerBase, Logger)
|
self._services.add_singleton(LoggerBase, Logger)
|
||||||
self._services.add_singleton(DatabaseConnectionBase, DatabaseConnection)
|
self._logger = self._services.get_service(LoggerBase)
|
||||||
self._logger: Logger = self._services.get_service(LoggerBase)
|
|
||||||
self._logger.create()
|
self._logger.create()
|
||||||
self._db_connection: DatabaseConnection = self._services.get_service(DatabaseConnectionBase)
|
|
||||||
self._db_connection.create()
|
|
||||||
|
|
||||||
def main(self):
|
def main(self):
|
||||||
self._logger.header(f'{self._configuration.environment.application_name}:')
|
self._logger.header(f'{self._configuration.environment.application_name}:')
|
||||||
|
Loading…
Reference in New Issue
Block a user