node-ts / bus

A typescript based enterprise service bus framework based on enterprise integration patterns
https://bus.node-ts.com/
MIT License
272 stars 25 forks source link

Construct workflows using container during mapping #157

Closed adenhertog closed 2 years ago

adenhertog commented 3 years ago

Task workflow-registry.ts:87 constructs an instance, rather than getting it from the container when a container is available. The standard runtime behaviour is to pull it from the container (workflow-registry.ts:155), and it'd be good to have this consistent so that access to dependencies is available during startup & mapping.

Background Per discord with Roustalski

Actually, for the second, I was able to use the Workflow pattern to achieve what we were trying to accomplish. It allows us to specify handlers in a single place, but also allows us to use our injection tool to pass off messages to a service However, we can't use injected variables during the configuration of the workflow since an instance is created by the registry just to setup the mapper. I have a workaround, but I think the container should be used in order to create the instance to configure the mapper rather than newing it up directly