Kaci

Kaci

  • 923
  • 816
  • 630

How to manage several instances of a class consuming the same API ?

May 21 2024 1:33 PM

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 !


Answers (1)