Hey guys, I have a question about the usage of DI. I come from the java & SpringBoot world but looking at the documentation and testing it myself, it seems to me that it works quite differently. My "java developer" instinct is to create a class and inject it into let's say a controller.
It seems to be instantiating the dependency every time unless I use use_cache=True , so essentially my dependency class is not a true singleton(I guess this concept is not really a thing in python).
I want to eagerly initialize the dependency class. It seems to be initializing it when I make my first API call when it needs to invoke it. The issue with lazy initialization is that my init method needs to load a bunch of files to memory and the server shouldn't really be considered running until this is done.
Looking at the above points, what is the practice you recommend? This is a pretty basic use-case of having a controller class for the api logic and a service class for the actual processing and business logic. Should I drop the whole "service class" approach and just create static methods and DI the processing method instead of the whole class?