whats the best patterns for configuring providers for resources which are sometimes not available #304
Unanswered
RonnyPfannschmidt
asked this question in
Q&A
Replies: 1 comment 6 replies
-
|
Sorry, I didn't get the problem. Isn't that what you expect? class Config:
pass
class Client:
def __init__(self, config: Config):
pass
class MyProvider(Provider):
@provide(scope=Scope.APP)
def get_config(self) -> Config:
raise ValueError("Config is not available")
client = provide(Client, scope=Scope.REQUEST)
container = make_container(MyProvider())
with container() as c:
c.get(Client)Error: |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
im having a dishka configuration where im composing a larger number of providers
some of those providers are unable to provide their objects in certain environments
for example the provider for kafka consumers/producers is only able to provide them when either the environment provide by k8s provides them as secrets or a alternative is added to a local configuration
so if a configruation is avaliable (which is known by a resource instead of at provider creation time) im able to create the client, else im not
im currently using something like
Beta Was this translation helpful? Give feedback.
All reactions