PISAresearch / pisa

Accountable Watching Service
https://pisa.watch
28 stars 9 forks source link

Create or integrate a framework to handle service dependencies #412

Open bigspider opened 4 years ago

bigspider commented 4 years ago

We should either integrate some existing dependency injection framework, or make our own.

An ad-hoc solution could be to have a ServiceManager that handles starting and stopping services, handling dependencies between services. Possible specs:

I thought initially to have separate "init" and "start", for example to register an event listener on a different service before actually starting (e.g. the blockchainMachine listening to newBlock), but I guess the constructor is a good place for that.

Now the idea is that the main service (e.g. the payment gateway) can become a service just like all the others, and it's the only thing that should be started "top-level", as it depends on the right services.