enthought / envisage

Envisage is a Python-based framework for building applications whose functionalities can be extended by adding "plug-ins".
http://docs.enthought.com/envisage/
Other
82 stars 26 forks source link

Document patterns for services that depend on other services #453

Open mdickinson opened 2 years ago

mdickinson commented 2 years ago

The Envisage service docs are explicit that:

To get the job done, services obviously need to interact, and so Envisage provides a way for them to find each other. This is where the service registry comes in.

This turns up in real projects: for example, a service that provides remote compute facilities might depend on a database service (to store inputs and outputs for the compute jobs).

However, we're missing documentation on good patterns for this; it would be good to fix that.

A pattern that doesn't work well is to instantiate the dependent services at ServiceOffer creation time - that can lead to issues with ordering of plugin startups. A better pattern is to instantiate the dependent services when the ServiceOffer object's factory is called (which should happen after all the service offers have been contributed to the service registry). That typically means passing the service registry object as a parameter to that factory. (Or the application, but the service factory will be easier to test if it doesn't require a fully-baked application object.)