Improved service providing and app hosting
This commit is contained in:
@@ -3,6 +3,8 @@ from datetime import datetime
|
||||
|
||||
from sh_edraft.configuration.configuration import Configuration
|
||||
from sh_edraft.configuration.base.configuration_base import ConfigurationBase
|
||||
from sh_edraft.hosting.base.environment_base import EnvironmentBase
|
||||
from sh_edraft.hosting.hosting_environment import HostingEnvironment
|
||||
from sh_edraft.hosting.application_runtime import ApplicationRuntime
|
||||
from sh_edraft.hosting.base.application_host_base import ApplicationHostBase
|
||||
from sh_edraft.service.service_provider import ServiceProvider
|
||||
@@ -17,7 +19,8 @@ class ApplicationHost(ApplicationHostBase):
|
||||
self._args: list[str] = sys.argv
|
||||
|
||||
self._config = Configuration()
|
||||
self._app_runtime = ApplicationRuntime(self._config)
|
||||
self._environment = HostingEnvironment()
|
||||
self._app_runtime = ApplicationRuntime(self._config, self._environment)
|
||||
self._services = ServiceProvider(self._app_runtime)
|
||||
|
||||
self._start_time: datetime = datetime.now()
|
||||
@@ -27,6 +30,10 @@ class ApplicationHost(ApplicationHostBase):
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def environment(self) -> EnvironmentBase:
|
||||
return self._environment
|
||||
|
||||
@property
|
||||
def configuration(self) -> ConfigurationBase:
|
||||
return self._config
|
||||
|
@@ -1,21 +1,27 @@
|
||||
from datetime import datetime
|
||||
|
||||
from sh_edraft.configuration.base import ConfigurationBase
|
||||
from sh_edraft.configuration.base.configuration_base import ConfigurationBase
|
||||
from sh_edraft.hosting.base.environment_base import EnvironmentBase
|
||||
from sh_edraft.hosting.base.application_runtime_base import ApplicationRuntimeBase
|
||||
|
||||
|
||||
class ApplicationRuntime(ApplicationRuntimeBase):
|
||||
|
||||
def __init__(self, config: ConfigurationBase):
|
||||
def __init__(self, config: ConfigurationBase, runtime: EnvironmentBase):
|
||||
ApplicationRuntimeBase.__init__(self)
|
||||
|
||||
self._configuration = config
|
||||
self._app_runtime = runtime
|
||||
self._app_configuration = config
|
||||
self._start_time: datetime = datetime.now()
|
||||
self._end_time: datetime = datetime.now()
|
||||
|
||||
@property
|
||||
def environment(self) -> EnvironmentBase:
|
||||
return self._app_runtime
|
||||
|
||||
@property
|
||||
def configuration(self) -> ConfigurationBase:
|
||||
return self._configuration
|
||||
return self._app_configuration
|
||||
|
||||
@property
|
||||
def start_time(self) -> datetime:
|
||||
|
@@ -1,6 +1,7 @@
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
from sh_edraft.configuration.base.configuration_base import ConfigurationBase
|
||||
from sh_edraft.hosting.base.environment_base import EnvironmentBase
|
||||
from sh_edraft.service.base.service_provider_base import ServiceProviderBase
|
||||
|
||||
|
||||
@@ -13,6 +14,10 @@ class ApplicationHostBase(ABC):
|
||||
@abstractmethod
|
||||
def name(self) -> str: pass
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def environment(self) -> EnvironmentBase: pass
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def configuration(self) -> ConfigurationBase: pass
|
||||
|
@@ -1,7 +1,8 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from datetime import datetime
|
||||
|
||||
from sh_edraft.configuration.base import ConfigurationBase
|
||||
from sh_edraft.configuration.base.configuration_base import ConfigurationBase
|
||||
from sh_edraft.hosting.base.environment_base import EnvironmentBase
|
||||
|
||||
|
||||
class ApplicationRuntimeBase(ABC):
|
||||
@@ -9,6 +10,10 @@ class ApplicationRuntimeBase(ABC):
|
||||
@abstractmethod
|
||||
def __init__(self): pass
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def environment(self) -> EnvironmentBase: pass
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def configuration(self) -> ConfigurationBase: pass
|
||||
|
@@ -6,7 +6,7 @@ from sh_edraft.hosting.model.environment_name import EnvironmentName
|
||||
|
||||
class HostingEnvironment(EnvironmentBase):
|
||||
|
||||
def __init__(self, name: EnvironmentName = None, crp: str = './'):
|
||||
def __init__(self, name: EnvironmentName = EnvironmentName.production, crp: str = './'):
|
||||
EnvironmentBase.__init__(self)
|
||||
|
||||
self._name: Optional[EnvironmentName] = name
|
||||
|
Reference in New Issue
Block a user