You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+70Lines changed: 70 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,6 +33,76 @@ FluxQueue is a task queue for Python that gets out of your way. The Rust core ma
33
33
- Redis server
34
34
- Linux (Windows and macOS support coming soon)
35
35
36
+
## Installation
37
+
38
+
```bash
39
+
pip install fluxqueue[cli]
40
+
```
41
+
42
+
## Example
43
+
44
+
`tasks.py`
45
+
46
+
```py
47
+
from fluxqueue import FluxQueue
48
+
49
+
# Create a FluxQueue instance (defaults to redis://127.0.0.1:6379)
50
+
fluxqueue = FluxQueue()
51
+
52
+
# Define a task using the @fluxqueue.task decorator
53
+
@fluxqueue.task()
54
+
defsend_email(to: str, subject: str, body: str):
55
+
print(f"Sending email to {to}")
56
+
print(f"Subject: {subject}")
57
+
print(f"Body: {body}")
58
+
```
59
+
60
+
## Enqueue Tasks
61
+
62
+
Call the decorated function to enqueue it. The function returns immediately, the actual work happens in the background:
63
+
64
+
```python
65
+
# Enqueue the task
66
+
send_email("user@example.com", "Hello", "This is a test email")
67
+
```
68
+
69
+
The task is now in the queue, waiting to be processed by a worker.
70
+
71
+
## Async Tasks
72
+
73
+
FluxQueue supports async functions too. Just define an async function and use the same decorator:
74
+
75
+
```python
76
+
@fluxqueue.task()
77
+
asyncdefprocess_data(data: dict):
78
+
# Your async processing logic
79
+
result =await some_async_operation(data)
80
+
return result
81
+
82
+
# Enqueue it (use await in async contexts)
83
+
await process_data({"key": "value"})
84
+
```
85
+
86
+
## Installing the worker
87
+
88
+
In order the tasks to be executed you need to run a fluxqueue worker, you need to install the worker on your system with:
89
+
90
+
```bash
91
+
fluxqueue worker install
92
+
```
93
+
94
+
It picks the latest released worker based on your python version and installs it. You can also pass `--version` argument to specify the version you want to install.
95
+
96
+
## Running the worker
97
+
98
+
Running the worker is straightforward:
99
+
100
+
```bash
101
+
fluxqueue start --tasks-module-path tasks
102
+
```
103
+
104
+
In order the worker to disover your tasks you need to pass `--tasks-module-path` argument with the path to the tasks module. For more information please view the [documentation](https://fluxqueue.ccxlv.dev/tutorial/defininig_and_exposing_tasks).
105
+
36
106
## License
37
107
38
108
FluxQueue is licensed under the Apache-2.0 license. See [LICENSE](LICENSE) for details.
0 commit comments