CLI#
FastStream has its own built-in CLI tool for your maximum comfort as a developer.
Thanks to typer and watchfiles. Their work is the basis of this tool.
Usage: faststream [OPTIONS] COMMAND [ARGS]...
Generate, run and manage FastStream apps to greater development experience
Options:
-v, --version Show current platform, python and FastStream
version
--install-completion [bash|zsh|fish|powershell|pwsh]
Install completion for the specified shell.
--show-completion [bash|zsh|fish|powershell|pwsh]
Show completion for the specified shell, to
copy it or customize the installation.
--help Show this message and exit.
Commands:
docs AsyncAPI schema commands
run Run [MODULE:APP] FastStream application
Running the Project#
Multiprocessing Scaling#
FastStream allows you to scale application right from the command line by running you application in the Process pool.
Just set the --worker
option to scale your application:
INFO - Started parent process [7591]
INFO - Started child process [7593]
INFO - Started child process [7594]
INFO - test | - `Handle` waiting for messages
INFO - test | - `Handle` waiting for messages
Hot Reload#
Thanks to watchfiles, written in Rust, you can work with your project easily. Edit the code as much as you like - the new version has already been launched and is waiting for your requests!
INFO - Started reloader process [7902] using WatchFiles
INFO - FastStream app starting...
INFO - test | - `Handle` waiting for messages
INFO - FastStream app started successfully! To exit press CTRL+C
Environment Management#
You can pass any custom flags and launch options to the FastStream CLI even without first registering them. Just use them when launching the application - and they will be right in your environment.
Use this option to select environment files, configure logging, or at your discretion.
For example, we will pass the .env file to the context of our application:
INFO - FastStream app starting...
INFO - test | - `Handle` waiting for messages
INFO - FastStream app started successfully! To exit press CTRL+C
Note
Note that the env
parameter was passed to the setup
function directly from the command line
All passed values can be of type bool
, str
or list[str]
.
In this case, the flags will be interpreted as follows:
faststream run app:app --flag # flag = True
faststream run app:app --no-flag # flag = False
faststream run app:app --my-flag # my_flag = True
faststream run app:app --key value # key = "value"
faststream run app:app --key 1 2 # key = ["1", "2"]
You can use them both individually and together in unlimited quantities.
AsyncAPI Schema#
Also, the FastStream CLI allows you to work with the AsyncAPI schema in a simple way.
You are able to generate .json
or .yaml
files by your application code or host HTML representation directly:
Usage: faststream docs [OPTIONS] COMMAND [ARGS]...
AsyncAPI schema commands
Options:
--help Show this message and exit.
Commands:
gen Generate project AsyncAPI schema
serve Serve project AsyncAPI schema
To learn more about the commands above, please visit AsyncAPI export and AsyncAPI hosting.