Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add provides ressource to service builder #168

Open
sebastianwessel opened this issue Mar 3, 2024 · 0 comments · May be fixed by #169
Open

feat: add provides ressource to service builder #168

sebastianwessel opened this issue Mar 3, 2024 · 0 comments · May be fixed by #169
Assignees
Labels
enhancement add or extend existing functionality feature request requesting a new feature improvement improved code or handling testing Related to testing

Comments

@sebastianwessel
Copy link
Member

A service acts as container for commands and subscriptions.
In real world, commands and subscriptions will need resources like database connections.

Instead of writing custom classes or to directly import connections, it might make sense, if the service builder gets a .provides method.

The service builder:

serviceBuilder.provides<TypeOfRessource>('database', 'a short description for database ressource')

Command and subscription functions:

.setCommandFunction(async function ( { resources }, _payload, parameter) {
   const { database } = resources
})

This also allows better testing, as the resources can be stubbed via the mock context.

const context = getCommandContextMock(payload, parameter, sandbox)
context.stubs. resources.database = sandbox.stub()

Also, later on, it can be used for documentation and visualization.

@sebastianwessel sebastianwessel added enhancement add or extend existing functionality testing Related to testing feature request requesting a new feature improvement improved code or handling labels Mar 3, 2024
@sebastianwessel sebastianwessel self-assigned this Mar 3, 2024
@sebastianwessel sebastianwessel linked a pull request Jul 26, 2024 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement add or extend existing functionality feature request requesting a new feature improvement improved code or handling testing Related to testing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant