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

Lifespan question #2

Open
cardosofede opened this issue Apr 28, 2024 · 5 comments
Open

Lifespan question #2

cardosofede opened this issue Apr 28, 2024 · 5 comments

Comments

@cardosofede
Copy link

Hey, First of all thanks for this initiative, it's great!
I have a question regarding the lifespan to manage objects.
Let's say that I would like to provide realtime data, and I have an object that subscribes via ws and keeps certain data updated, so I can expose a route to provide this data aggregated. Should I create the object with the lifespan approach? Or which is your recommendation?

@Praveenstein
Copy link

Great question, I'm curious for the reply by experts, been working on something similar.

@Kludex
Copy link
Owner

Kludex commented Apr 29, 2024

Can you give me an MRE? (GitHub repository with minimal setup would be great.)

@Kludex
Copy link
Owner

Kludex commented Apr 30, 2024

I'll reopen if you reply.

@Kludex Kludex closed this as completed Apr 30, 2024
@cardosofede
Copy link
Author

Sorry I just saw the message, will create one tomorrow

@cardosofede
Copy link
Author

cardosofede commented May 10, 2024

@Kludex hey, I have an example here: https://github.com/hummingbot/backend-api/blob/feat/add_market_data/routers/manage_market_data.py

I'm thinking about creating an endpoint to start a candles and stop the candles from a collection and if you ask for the realtime candles instead of creating and initializing the object will be just using the active candles.

As a reference, this is the class that we use in Hummingbot to keep the most updated length required of candles that are running: https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/market_data_provider.py

@Kludex Kludex reopened this May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants