question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for Services that need a async setup

See original GitHub issue

There are several examples where a Service needs a async step to be completely initialised. For example database connections:

https://github.com/L2jLiga/fastify-decorators/blob/v3/examples/typeorm/src/services/connection.service.ts https://github.com/L2jLiga/fastify-decorators/blob/v3/examples/typeorm/src/facades/message.facade.ts

A basic way to do this would be to look for a promise property named ready (or even better, a symbol to avoid collisions) on a service and await on them before starting the server.

A more advanced way, which can be done afterwards, would be a decorator on an async function but a Service may require other Services have inited so this is more tricky and require a big time investment.

The good news is the basic way does not conflict with the more advanced way so it can be built separately and be supported independently. Also the init dependency graph can be manually solved with the basic version by awaiting the other services to init.

What do you think? I would be happy to do a PR for the basic one, as I need it 😄

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
mihai1voicescucommented, Oct 13, 2020

Had some personal issues, sorry. It’s almost done and I think I have time to work on it tomorrow. Sorry it took so long.

1reaction
mihai1voicescucommented, Sep 28, 2020

Had some problems during the weekend and didn’t get to finish. Gona try and finish these days.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to: Provide an Asynchronous Visual Studio Service
Learn how to provide an asynchronous Visual Studio service. This approach allows you to obtain a service without blocking the UI thread.
Read more >
Built in options for running async tasks
In this post I look at the problem of running one-off tasks asynchronously on app startup in ASP.NET Core, and explore the pros...
Read more >
Working with Async | Home Assistant Developer Docs
For platforms we support async setup. Instead of setup_platform you need to have a coroutine async_setup_platform.
Read more >
Getting Started | Creating Asynchronous Methods - Spring
Navigate to https://start.spring.io. This service pulls in all the dependencies you need for an application and does most of the setup for you....
Read more >
How To Do @Async in Spring - Baeldung
Enable Async Support. Let's start by enabling asynchronous processing with Java configuration. We'll do this by adding the @EnableAsync to a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found