You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a CLI that I am attempting to refactor, where in it I have a concept of Services. This is a list of configurable objects, but all should be derived from a common base object.
The documentation points to providers.List, which seemed promising except it requires arguments to be coded.
From it, Services is an array of different service types.
class BaseService:
def __init__(self, Name):
self.Name = Name
def perform(self):
pass
class CloudWatchService(BaseService):
def __init__(self, Name):
self.Name = Name
def perform(self):
logger.debug("CloudWatchService")
class S3Service(BaseService):
def __init__(self, Name):
self.Name = Name
def perform(self):
logger.debug("S3Service")
class Failover:
"""
Contains Activities, Services, and Configuration, while also responsible for providing EffectiveActivities.
"""
def __init__(self, Activities, Services, Configuration):
self.Activities = Activities
self.Services = Services
self.Configuration = Configuration
class Environment:
"""
Provides for a selectable environment, such as Dev, Qa, and Prod containing the full graph of Failover configuration.
"""
def __init__(self, Failover):
self.Failover = Failover
class Resources:
def __init__(self, Environment):
self.Environment = Environment
class Cli:
def __init__(self, Version, Resources):
self.Version = Version
self.Resources = Resources
When creating a container, this works, except the Services are still a dictionary and not converted to classes:
Thank you for this clean DI framework!
I have a CLI that I am attempting to refactor, where in it I have a concept of Services. This is a list of configurable objects, but all should be derived from a common base object.
The documentation points to providers.List, which seemed promising except it requires arguments to be coded.
Here is a picture of our configuration:
From it,
Services
is an array of different service types.When creating a container, this works, except the Services are still a dictionary and not converted to classes:
Here is my test:
How can create list of derived objects based from the configuration loaded at runtime?
The text was updated successfully, but these errors were encountered: