-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Description
Is there a way to implement transient or scoped dependency? I am thinking of a way to create services that would only exist for the life of the api request in FastApi. E.g. let’s say you get a message with 2 different sections:
[
{trees: [ {tree: {id: 1, desc: “pine”}, …]
{dogs: [ {dog: {id: 1, name: “potato”}, …]
]
When I receive this message I want to use a TreeProvider and DogProvider that source their data from the above message and can be injected just for processing that request and not for other requests.
@inject() #message will be injected
def class DogProvider(IDogProvider):
def __init__(self, message):
…
def get_dogs() -> Dog:
…
@inject() #message will be injected
def class TreeProvider(ITreeProvider):
def __init__(self, message)
…
def get_trees() -> Tree:
…
This is similar to a C# scoped or transient registration.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels