Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/available-components/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dir:

# Available components

In this section, you can find a list of officially supported plugins for the taskiq.
In this section, you can find a list of officially supported plugins for taskiq.

- [Available brokers](./brokers.md)
- [Available middlewares](./middlewares.md)
Expand Down
10 changes: 5 additions & 5 deletions docs/available-components/brokers.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ If you choose this type of broker, please run taskiq with `-w 1` parameter,
otherwise you may encounter undefined behavior.
:::

To run this broker please install the [pyzmq](https://pypi.org/project/pyzmq/) lib. Or you can taskiq with `zmq` extra.
To run this broker please install the [pyzmq](https://pypi.org/project/pyzmq/) lib. Or you can install taskiq with `zmq` extra.

::: tabs

Expand Down Expand Up @@ -56,7 +56,7 @@ def my_task() -> bool:
return True
```

To kiq this task you have to options:
To kiq this task you have two options:

- Explicitly define broker using kicker for this kiq;
- Add default broker for all shared tasks.
Expand All @@ -82,8 +82,8 @@ await my_task.kicker().with_broker(broker).kiq()

## Custom brokers

These brokers are not parts of the core Taskiq lib. But they are maintained by Taskiq developers.
You can install them as a separate packages.
These brokers are not part of the core Taskiq lib. But they are maintained by Taskiq developers.
You can install them as separate packages.

You can read more about parameters and abilities of these brokers in README.md of each repo.

Expand Down Expand Up @@ -130,7 +130,7 @@ pip install taskiq-aio-kafka

## Third-party brokers

These brokers are not part of the core Taskiq library. They are maintained by other open‑source contributors. You can install them as a separate packages.
These brokers are not part of the core Taskiq library. They are maintained by other open‑source contributors. You can install them as separate packages.

You can read more about parameters and abilities of these brokers in README.md of each repo.

Expand Down
4 changes: 2 additions & 2 deletions docs/available-components/result-backends.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This broker will always return `None` for any return_value. Please be careful.

## Official result backends

This result backends is not part of the core Taskiq library. But they are maintained by Taskiq developers. You can install them as a separate package.
These result backends are not part of the core Taskiq library. But they are maintained by Taskiq developers. You can install them as a separate package.

### Redis result backend

Expand Down Expand Up @@ -50,7 +50,7 @@ pip install taskiq-sqs

## Third-party result backends

These result backends are not part of the core Taskiq library. They are maintained by other open‑source contributors. You can install them as a separate packages.
These result backends are not part of the core Taskiq library. They are maintained by other open‑source contributors. You can install them as separate packages.

### PostgreSQL result backend

Expand Down
4 changes: 2 additions & 2 deletions docs/available-components/schedule-sources.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Parameters:
- `cron` - crontab string when to run the task.
- `cron_offset` - timezone offset for cron values. Explained [here](../guide/scheduling-tasks.md#working-with-timezones)
- `interval` - Interval to run periodic tasks. Must be at least 1 second and cannot have fractional seconds.
- `time` - specific time when send the task.
- `time` - specific time when to send the task.
- `args` - args to use, when invoking the task.
- `kwargs` - key-word arguments to use when invoking the task.
- `labels` - additional labels to use when invoking the task.
Expand Down Expand Up @@ -105,7 +105,7 @@ This schedule source doesn't use `schedule` label on tasks. To add new schedules

## Third-party schedule sources

These schedule sources are not part of the core Taskiq library. They are maintained by other open‑source contributors. You can install them as a separate packages.
These schedule sources are not part of the core Taskiq library. They are maintained by other open‑source contributors. You can install them as separate packages.

### PostgreSQL schedule source

Expand Down
8 changes: 4 additions & 4 deletions docs/contrib.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ We have several rules for contributors:
* Please do not add malware.
* Please make sure that your request solves the problem.

If you struggle with something or feel frustrated, you either create an issue, create a [discussions](https://github.com/orgs/taskiq-python/discussions).
If you struggle with something or feel frustrated, you either create an issue, create a [discussions](https://github.com/orgs/taskiq-python/discussions)
page or publish a draft PR and ask your question in the description.

We have lots of tests in CI. But since CI runs from first-time contributors should be approved, you better test locally. It just takes less time to prepare PR for merging.
We have lots of tests in CI. But since CI runs from first-time contributors need to be approved, you better test locally. It just takes less time to prepare PR for merging.

## Setting up environment

Expand Down Expand Up @@ -42,7 +42,7 @@ You can run `pytest` without any parameters and it will do the thing.
pytest
```

If you want to speedup testings, you can run it with `-n` option from [pytest-xdist](https://pypi.org/project/pytest-xdist/) to run tests in parallel.
If you want to speed up testing, you can run it with `-n` option from [pytest-xdist](https://pypi.org/project/pytest-xdist/) to run tests in parallel.

```bash
pytest -n 2
Expand Down Expand Up @@ -71,7 +71,7 @@ After that, you can run documentation server with hot-reloading using:
pnpm docs:dev
```

If you want to check how documentation looks like in production mode, you can build it and then serve using:
If you want to check how documentation looks in production mode, you can build it and then serve using:

```bash
pnpm docs:build
Expand Down
2 changes: 1 addition & 1 deletion docs/extending-taskiq/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ In the `exec` method, you should parse incoming arguments. But since all CLI arg

Also, you can use your favorite tool to build CLI, like [click](https://click.palletsprojects.com/) or [typer](https://typer.tiangolo.com/).

After you have such class, you need to add entrypoint that points to that class.
After you have such class, you need to add an entrypoint that points to that class.

::: tabs

Expand Down
2 changes: 1 addition & 1 deletion docs/extending-taskiq/middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ For example:

:::

Also, middlewares always have reference to the current broker in `self.broker` field.
Also, middlewares always have a reference to the current broker in `self.broker` field.
If you want to kick a message during the execution of some middleware hooks, you
may use `self.broker` to do so.

Expand Down
2 changes: 1 addition & 1 deletion docs/extending-taskiq/schedule-sources.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Here's a minimal example of a schedule source:

@[code python](../examples/extending/schedule_source.py)

You can implement a schedule source that write schedules in the database and have delayed tasks in runtime.
You can implement a schedule source that writes schedules in the database and have delayed tasks in runtime.

::: info Cool tip!
You can also use `LabelScheduleSource` as a base class for your schedule source
Expand Down
2 changes: 1 addition & 1 deletion docs/framework_integrations/taskiq-with-aiogram.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[Taskiq-Aiogram](https://github.com/taskiq-python/taskiq-aiogram) is a nice integration with one of the best telegram bot libraries - [aiogram](https://docs.aiogram.dev/en/latest/).

This integration allows you to easily send delayed messages or run intensive functions without blocking the message handing.
This integration allows you to easily send delayed messages or run intensive functions without blocking the message handling.

This integration adds three main dependencies which you can use in your taskiq functions:

Expand Down
4 changes: 2 additions & 2 deletions docs/framework_integrations/taskiq-with-aiohttp.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import aiohttp_deps
app = web.Application()

# This startup event makes all the magic happen.
# It parses current handlers and create dependency graphs for them.
# It parses current handlers and creates dependency graphs for them.
app.on_startup.append(aiohttp_deps.init)

web.run_app(app)
Expand Down Expand Up @@ -91,7 +91,7 @@ async def my_task(app: web.Application = TaskiqDepends()):

:::

In this example, we depend on the current application. We can use its state in a current task or any other dependency. We can take db_pool from your application's state, which is the same pool, as the one you've created on AiohTTP's startup.
In this example, we depend on the current application. We can use its state in a current task or any other dependency. We can take db_pool from your application's state, which is the same pool, as the one you've created on AioHTTP's startup.
But this application is only a mock of your application. It has correct types and all your variables that you filled on startup, but it doesn't handle any request.
This integration adds two main dependencies:
* web.Application - current application.
Expand Down
2 changes: 1 addition & 1 deletion docs/framework_integrations/taskiq-with-fastapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ FastAPI is a highly popular async web framework in Python. It has gained its pop
1. It's easy to use;
2. Cool dependency injection.

In taskiq, we try to make our libraries easy to use, and We have a dependency injection too. So we have created the library "[taskiq-fastapi](https://github.com/taskiq-python/taskiq-fastapi)" to make integration with FastAPI as smooth as possible.
In taskiq, we try to make our libraries easy to use, and we have a dependency injection too. So we have created the library "[taskiq-fastapi](https://github.com/taskiq-python/taskiq-fastapi)" to make integration with FastAPI as smooth as possible.

Let's see what we got here. In this library, we provide users with only one public function called `init`. It takes a broker and a string path (as in uvicorn) to the fastapi application (or factory function). People should call this function in their main broker file.

Expand Down
8 changes: 4 additions & 4 deletions docs/guide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Taskiq is a library that helps you send and process python functions in a distri
For example, you have many heavy to calculate functions you want to execute on another server.
You can implement interservice communication by yourself, or you can use Taskiq to make the job done easily.

The core library doesn't have much functionality. It provides two built-in brokers, CLI, basic functionality for creating distributed tasks, and abstractions to extend the taskiq. The main idea of taskiq is to make it modular and easy to extend. We have libraries for many
possible use cases, but if you lack something, you can adopt taskiq to fit your needs.
The core library doesn't have much functionality. It provides two built-in brokers, CLI, basic functionality for creating distributed tasks, and abstractions to extend taskiq. The main idea of taskiq is to make it modular and easy to extend. We have libraries for many
possible use cases, but if you lack something, you can adapt taskiq to fit your needs.

## Why not use existing libraries?

Expand All @@ -26,9 +26,9 @@ You might have seen projects built on top of asyncio that solve a similar proble
| Actively maintained | ✅ | ❌ | ❌ | ✅ |
| Multiple broker backends | ✅ | ❌ | ✅ | ❌ |
| Multiple result backends | ✅ | ❌ | ❌ | ❌ |
| Have a rich documentation | ✅ | ❌ | ❌ | ✅ |
| Rich documentation | ✅ | ❌ | ❌ | ✅ |
| Startup & Shutdown events | ✅ | ✅ | ❌ | ✅ |
| Have ability to abort tasks | ❌ | ✅ | ❌ | ✅ |
| Ability to abort tasks | ❌ | ✅ | ❌ | ✅ |
| Custom serializers | ✅ | ✅ | ❌ | ✅ |
| Dependency injection | ✅ | ❌ | ❌ | ❌ |
| Task pipelines | ✅ | ✅ | ❌ | ✅ |
Expand Down
28 changes: 14 additions & 14 deletions docs/guide/architecture-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ order: 3

# Architecture overview

Taskiq has very simple structure.
Taskiq has a very simple structure.
On the client side all messages are sent by `kickers` using `brokers`.
On the worker side all messages received by the `broker` and results are stored in result backends.
On the worker side all messages are received by the `broker` and results are stored in result backends.

On the sequence diagram it looks like this:

Expand Down Expand Up @@ -35,7 +35,7 @@ Let's discuss every component.

## Broker

Brokers are the most critical element of the taskiq. Every broker **must** implement the `AsyncBroker` abstract class from [taskiq.abc.broker](https://github.com/taskiq-python/taskiq/blob/master/taskiq/abc/broker.py) to make things work.
Brokers are the most critical element of taskiq. Every broker **must** implement the `AsyncBroker` abstract class from [taskiq.abc.broker](https://github.com/taskiq-python/taskiq/blob/master/taskiq/abc/broker.py) to make things work.

`AsyncBroker` class has two main methods to implement:

Expand All @@ -49,7 +49,7 @@ The `listen` is a method with an infinite loop that reads messages from the exte

## Kicker

Kicker is an object that used to form a message for broker. This class isn't extendable.
Kicker is an object that is used to form a message for a broker. This class isn't extendable.
To form a message kicker uses labels, task name and arguments.

When you call the `task.kiq` on a task, it generates a Kicker instance and is a shortening for the `task.kicker().kiq(...)`. You can use kicker to change broker, add labels, or even change task_id.
Expand Down Expand Up @@ -122,7 +122,7 @@ Also you can assign custom task names using decorator.
This is useful to be sure that task names are unique and resolved correctly.
Also it may be useful to balance message routing in some brokers.

for example:
For example:

```python
@broker.task(task_name="my_tasks.add_one", label1=1)
Expand All @@ -147,7 +147,7 @@ Taskiq has a command line interface to run workers.
It's simple to get it to work.

You have to provide a path to your broker. As an example, if you want to start listening to new tasks
with a broker that is stored in a variable `my broker` in the module `my_project.broker` run this in your terminal:
with a broker that is stored in a variable `mybroker` in the module `my_project.broker` run this in your terminal:

```
taskiq worker my_project.broker:mybroker
Expand Down Expand Up @@ -179,7 +179,7 @@ Or you can let taskiq find all python modules named tasks in current directory r
taskiq worker test_project.broker:broker -fsd
```

If you have uvloop installed, taskiq will automatically install new policies to event loop.
If you have uvloop installed, taskiq will automatically install new policies to the event loop.
You can get more info about the CLI in the [CLI](./cli.md) section.

::: info Cool info
Expand All @@ -190,8 +190,8 @@ By default we start two processes, if you want to change this value, please take

## Middlewares

Middlewares are used to modify message, or take
some actions before or after task is complete.
Middlewares are used to modify a message, or take
some actions before or after the task is complete.

You can write your own middlewares by subclassing
the `taskiq.abc.middleware.TaskiqMiddleware`.
Expand Down Expand Up @@ -223,15 +223,15 @@ Here are methods you can implement in the order they are executed:
- `pre_send` - executed on the client side before the message is sent. Here you can modify the message.
- `post_send` - executed right after the message was sent.
- `pre_execute` - executed on the worker side after the message was received by a worker and before its execution.
- `on_error` - executed after the task was executed if the exception was found.
- `on_error` - executed after the task was executed if an exception was found.
- `post_execute` - executed after the message was executed.
- `post_save` - executed after the result was saved in the result backend.

You can use sync or async hooks without changing anything, but adding async to the hook signature.

::: warning important note

If exception happens in middlewares it won't be caught. Please ensure that you have try\except for all edge cases of your middleware.
If an exception happens in middlewares it won't be caught. Please ensure that you have try/except for all edge cases of your middleware.

:::

Expand All @@ -242,9 +242,9 @@ to remember number of failed attempts.
## Context

Context is a useful class with some additional functions.
You can use context to get broker that runs this task, from inside of the task.
You can use context to get the broker that runs this task, from inside the task.

Or it has ability to control the flow of execution. Here's example of how to get
Or it has the ability to control the flow of execution. Here's an example of how to get
the context.

::: tabs
Expand Down Expand Up @@ -307,4 +307,4 @@ Calling `requeue` or `reject` stops task execution and either drops the message,
or puts it back to the queue.

Also, with context you'll be able to get current message that was received by the broker
or even instance of a broker who received a message. This may be useful for lib developers.
or even an instance of a broker that received a message. This may be useful for lib developers.
18 changes: 9 additions & 9 deletions docs/guide/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ order: 4

# CLI

Core library comes with CLI program called `taskiq`, which is used to run different subcommands.
The core library comes with a CLI program called `taskiq`, which is used to run different subcommands.

By default taskiq is shipped with only two commands: `worker` and `scheduler`. You can search for more taskiq plugins
using pypi. Some plugins may add new commands to taskiq.
Expand Down Expand Up @@ -37,7 +37,7 @@ By default taskiq uses **threadpool**. Here are some worker CLI options that can
### Auto importing

Enumerating all modules with tasks is not an option sometimes.
That's why taskiq can auto-discover tasks in current directory recursively.
That's why taskiq can auto-discover tasks in the current directory recursively.

We have two options for this:

Expand All @@ -47,7 +47,7 @@ We have two options for this:

### Acknowledgements

The taskiq supports four types of acknowledgements:
Taskiq supports four types of acknowledgements:
* `when_received` - task is acknowledged when it is **received** by the worker.
* `when_executed` - task is acknowledged right after it is **executed** by the worker.
* `when_saved` - task is acknowledged when the result of execution is saved in the result backend.
Expand Down Expand Up @@ -83,18 +83,18 @@ Manual acknowledgement requires a broker that yields `AckableMessage`.

### Type casts

One of features taskiq have is automatic type casts. For example you have a type-hinted task like this:
One of the features taskiq has is automatic type casts. For example you have a type-hinted task like this:

```python
async def task(val: int) -> int:
return val + 1
```

If you'll call `task.kiq("2")` you'll get 3 as the returned value. Because we parse signatures of tasks and cast incoming parameters to target types.
If type-cast fails you won't throw any error. It just leave the value as is. That functionality allows you to use pydantic models, or
If you call `task.kiq("2")` you'll get 3 as the returned value. Because we parse signatures of tasks and cast incoming parameters to target types.
If type-cast fails you won't throw any error. It just leaves the value as is. That functionality allows you to use pydantic models, or
dataclasses as the input parameters.

To disable this pass the `--no-parse` option to the taskiq.
To disable this pass the `--no-parse` option to taskiq.

### Hot reload

Expand Down Expand Up @@ -126,14 +126,14 @@ uv add taskiq[reload]

To enable this option simply pass the `--reload` or `-r` option to worker taskiq CLI.

You can set `--reload-dir` to specify directory to watch for changes. It can be specified multiple times if you need to watch multiple directories.
You can set `--reload-dir` to specify a directory to watch for changes. It can be specified multiple times if you need to watch multiple directories.

Also this option supports `.gitignore` files. If you have such file in your directory, it won't reload worker
when you modify ignored files. To disable this functionality pass `--do-not-use-gitignore` option.

### Graceful reload (available only on Unix systems)

To perform graceful reload, send `SIGHUP` signal to the main worker process. This action will reload all workers with new code. It's useful for deployment that requires zero downtime, but without using heavy orchestration tools like Kubernetes.
To perform graceful reload, send `SIGHUP` signal to the main worker process. This action will reload all workers with new code. It's useful for a deployment that requires zero downtime, but without using heavy orchestration tools like Kubernetes.


```bash
Expand Down
Loading
Loading