-
Notifications
You must be signed in to change notification settings - Fork 313
Feature/update docs #2457
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
Feature/update docs #2457
Conversation
… command - Added instruction to upgrade pip to fix `pip install --group` error - Fixed mkdocs serve errors by ensuring dependencies and environment setup - Verified changes do not affect other parts of the system - Ready to discuss any proposed changes and feedback
… command - Added instruction to upgrade pip to fix `pip install --group` error - Fixed mkdocs serve errors by ensuring dependencies and environment setup - Verified changes do not affect other parts of the system - Ready to discuss any proposed changes and feedback
Changed the documentation server startup instructions to use the `just docs-serve` command instead of directly running `mkdocs serve`.
…mmands - Changed documentation to use `just docs-serve` for starting the local docs server - Added note about using `just docs-serve --full` for a full build with all dependencies
…mmands - Changed documentation to use `just docs-serve` for starting the local docs server - Added note about using `just docs-serve --full` for a full build with all dependencies
Added a visual schema/table to the Lifespan Hooks documentation showing: - All existing hooks (`on_startup`, `after_startup`, `on_shutdown`, `after_shutdown`) - Their execution order - Available resources (CLI args, context, broker) for each hook This makes it easier to understand when hooks are called and what can be accessed at each stage.
| | Hook | CLI args | Context | Broker | | ||
| | ------------------- | -------- | ------ | ----- | | ||
| | **on\_startup** | ✅ | ✅ | ❌ | | ||
| | **after\_startup** | ❌ | ✅ | ✅ | | ||
| | **on\_shutdown** | ❌ | ✅ | ✅ | | ||
| | **after\_shutdown** | ❌ | ✅ | ❌ | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the Broker column if we are talking about whether the broker is running or not, then please add a mention of "Broker is running" or "Broker life" to make it clear.
If we are talking about whether we can get an instance of Broker, then we can in any hook.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'll fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Lancetnik In this example, I would like to indicate whether there is a connection to the broker. From the context, there is a possibility to obtain broker data, but I tried to indicate the broker connection. Perhaps I should change the line with the broker
| @app.after_startup | ||
| async def after_startup(logger: Logger): | ||
| logger.info("after_startup called") | ||
|
|
||
| @app.on_startup | ||
| async def first_start(logger: Logger): | ||
| logger.info("first_start called") | ||
|
|
||
| @app.on_startup | ||
| async def second_start(logger: Logger): | ||
| logger.info("second_start called") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add please full example:
@app.on_startup
@app.after_startup
@app.on_shutdown
@app.after_shutdown
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add it now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Kolanar does logger is accessible here in 0.6? I don't think so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Lancetnik The documentation for version 0.6 provides an illustration of how to obtain a logger. In my example, this was done to demonstrate the sequence of operations. If this example confuses you, please inform me, and I will provide an alternative example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Lancetnik I changed the example.
Added a complete example in the Lifespan Hooks documentation showing: - All four hook types (`on_startup`, `after_startup`, `on_shutdown`, `after_shutdown`) - Multiple functions per hook type - Execution order with formatted console output This improves clarity on how hooks are registered, executed, and in what order they appear in logs.
|
@Maclovi Please check the changes |
| logger.info("startup_first called") | ||
|
|
||
| @app.on_startup | ||
| async def startup_second(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's remove the duplicates? just add a note at the end that you can create many hooks
|
|
||
| # --- Shutdown hooks --- | ||
| @app.on_shutdown | ||
| async def shutdown_first(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here
|
|
||
| # --- After shutdown hooks --- | ||
| @app.after_shutdown | ||
| async def after_shutdown(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
| shutdown_second called | ||
| after_shutdown called | ||
| ``` | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
write here that it is possible to create multiple hooks of each type without examples, just text
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Maclovi Yes, well, I'll change the wording and the example.
theseriff
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need some changes
theseriff
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a mention of the possibility of adding multiple hooks
Description
docs: add lifecycle hooks schema with order and resource availability
Added a visual schema/table to the Lifespan Hooks documentation showing:
on_startup,after_startup,on_shutdown,after_shutdown)This makes it easier to understand when hooks are called and what can be accessed at each stage.
Fixes #2285
Type of change
Please delete options that are not relevant.
Checklist
just lintshows no errors)just test-coveragejust static-analysis