Skip to content

Commit 55ee341

Browse files
committed
version 0.0.1b2
0 parents  commit 55ee341

File tree

8 files changed

+906
-0
lines changed

8 files changed

+906
-0
lines changed

.gitignore

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# PyBuilder
59+
.pybuilder/
60+
target/
61+
62+
63+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
64+
__pypackages__/
65+
66+
# Environments
67+
.env
68+
.venv
69+
env/
70+
venv/
71+
ENV/
72+
env.bak/
73+
venv.bak/

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Sinan Bekar
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
## Python Laravel Queue
2+
3+
Queue sync between Python and Laravel using Redis driver. You can process jobs dispatched from Laravel in Python.
4+
5+
**NOTE: This package is in beta and only Redis is supported currently. Production usage is not recommended until stable release.**
6+
7+
In the 1.0.0 stable version these implementations are planned:
8+
9+
- Auto-discovery jobs in both Laravel and Python.
10+
- Auto-configuration by reading Laravel config in Python side.
11+
- More clean API.
12+
- Supporting more queue drivers.
13+
14+
### Install
15+
16+
```bash
17+
pip install python-laravel-queue
18+
```
19+
20+
### Usage
21+
22+
- Listen for jobs on Python:
23+
24+
```python
25+
from python_laravel_queue import Queue as PlQueue
26+
from redis import Redis
27+
28+
r = Redis(host='localhost', port=6379, db=0)
29+
queue_python = PlQueue(r, queue='python')
30+
31+
@queue_python.handler
32+
def handle(data):
33+
name = data['name'] # job name
34+
data = data['data'] # job data
35+
print('TEST: ' + data['a'] + ' ' + data['b'] + ' ' + data['c'])
36+
37+
queue_python.listen()
38+
```
39+
40+
- Sending jobs from Laravel :
41+
42+
```php
43+
<?php
44+
$job = new \App\Jobs\TestJob('hi','send to','python');
45+
dispatch($job)->onQueue('python');
46+
```
47+
48+
- Schedule a job to be run in Laravel from Python:
49+
50+
```python
51+
from python_laravel_queue import Queue as PlQueue
52+
from redis import Redis
53+
54+
r = Redis(host='localhost', port=6379, db=0)
55+
queue_laravel = PlQueue(r, queue='laravel')
56+
queue_laravel.push('App\\Jobs\\TestJob', {'a': 'hello', 'b': 'send to', 'c': 'laravel'})
57+
58+
```
59+
60+
**TestJob** in Laravel:
61+
62+
```php
63+
<?php
64+
65+
namespace App\Jobs;
66+
use Illuminate\Contracts\Queue\ShouldQueue;
67+
use Illuminate\Bus\Queueable;
68+
use Illuminate\Contracts\Queue\ShouldQueue;
69+
use Illuminate\Foundation\Bus\Dispatchable;
70+
use Illuminate\Queue\InteractsWithQueue;
71+
use Illuminate\Queue\SerializesModels;
72+
use Illuminate\Support\Facades\Log;
73+
74+
class TestJob extends Job implements ShouldQueue
75+
{
76+
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
77+
78+
public $a, $b, $c;
79+
80+
/**
81+
* Create a new job instance.
82+
*
83+
* @return void
84+
*/
85+
public function __construct ($a, $b, $c) {
86+
$this->a = $a;
87+
$this->b = $b;
88+
$this->c = $c;
89+
}
90+
91+
public function handle () {
92+
Log::info('TEST: ' . $this->a . ' '. $this->b . ' ' . $this->c);
93+
}
94+
}
95+
96+
```
97+
98+
- You need to :listen (or :work) the preferred queue name above to handle data sent from Python in Laravel.
99+
100+
```bash
101+
php artisan queue:listen --queue=laravel
102+
```

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[build-system]
2+
requires = [
3+
"setuptools>=42",
4+
"wheel"
5+
]
6+
build-backend = "setuptools.build_meta"

setup.cfg

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[metadata]
2+
name = python-laravel-queue
3+
version = 0.0.1b2
4+
author = Sinan Bekar
5+
author_email = sinanbekar.work@gmail.com
6+
description = Sync Laravel queue with Python.
7+
long_description = file: README.md
8+
long_description_content_type = text/markdown
9+
url = https://github.com/sinanbekar/python-laravel-queue
10+
project_urls =
11+
Bug Tracker = https://github.com/sinanbekar/python-laravel-queue/issues
12+
classifiers =
13+
Programming Language :: Python :: 3
14+
License :: OSI Approved :: MIT License
15+
Operating System :: OS Independent
16+
17+
[options]
18+
package_dir =
19+
= src
20+
packages = find:
21+
python_requires = >=3.6
22+
install_requires =
23+
redis
24+
pyee
25+
26+
27+
28+
[options.packages.find]
29+
where = src

src/python_laravel_queue/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__version__ = "0.0.1b2"
2+
from .queue import Queue

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy