Hi all, First of all I'm not an expert developer, just a self learned. I'm working on an automated system (let's call it class System) where I'm consumming a bunch of APIs and websockets from a broker. Therefore i'm of course limited in terms of API request per seconds (usually around 10/sec).
The issue is that I will need to create several instances of that class System running in parallel, and will most probably hit the rate limit. Even if I don't hit the rate limit, i'm not sure it's really nice to subscribe many times to the same websockets. So my question is : what is the best practice in that particular scenario ? The only idea that i started working on is:
1.Create a class "Core" that subscribe to the different websockets from that broker
2. An action event is raised everytime something is received in those sockets
3. That Core class can create as many instance of class System as I want. Those class A then subscribe to the different events I'm raising at step 2.
Now this is the issue, this is a bit complexe for my level as I need to create a wpf form to be able to manage all this mess properly. Indeed, each class System could have different parameters, so actually it would be an Interface rather than a class.
Would you guys have an easier idea maybe how to manage such a project ?
Many thanks in advance !
Loading
Jayraj ChhayaPosted May 21, 2024, 2:25 PM
To manage multiple instances of a class consuming the same API efficiently, consider implementing a centralized Core class that handles API subscriptions and event notifications. Each instance of the System class can then subscribe to events raised by the Core class, reducing redundant subscriptions and simplifying management.
Here's a simplified approach:
By centralizing API interactions in the Core class, you can avoid redundant subscriptions and streamline event management across multiple instances. This approach enhances scalability and maintainability while reducing complexity in managing different parameters for each System instance. Consider using interfaces to define common behavior and ensure flexibility in handling diverse System instances.