Created
August 5, 2023 03:48
-
-
Save FernandoCelmer/2f12967f5d2e93e39dd912bbecbe3615 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Model: | |
def __init__(self, config: dict) -> None: | |
self.config = config | |
class Producer: | |
def __new__(cls, config: dict, debug: bool): | |
if debug: | |
return super(Producer, cls).__new__(cls) | |
else: | |
return Model(config=config) | |
def __init__(self, config: dict, debug: bool = True) -> None: | |
self.new_queue = None | |
class Consumer: | |
def __new__(cls, config: dict, debug: bool): | |
if debug: | |
return super(Consumer, cls).__new__(cls) | |
else: | |
return Model(config=config) | |
def __init__(self, config: dict, debug: bool = True) -> None: | |
self.pendding = None | |
self.success = None | |
self.error = None | |
class Buider: | |
def __init__(self, config: dict, debug: bool) -> None: | |
self.config = config | |
self.debug = debug | |
self.producer = None | |
self.consumer = None | |
def new_producer(self): | |
self.producer = Producer( | |
config=self.config, debug=self.debug | |
) | |
return self.producer | |
def new_consumer(self): | |
self.consumer = Consumer( | |
config=self.config, debug=self.debug | |
) | |
return self.consumer | |
constructor = Buider(config={}, debug=True) | |
constructor.new_producer() | |
constructor.new_consumer() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment