Skip to content

Commit

Permalink
PyPi Release.
Browse files Browse the repository at this point in the history
  • Loading branch information
debonzi committed Sep 25, 2017
1 parent 535df62 commit 7a66f13
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 11 deletions.
20 changes: 20 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
This is the MIT license: http://www.opensource.org/licenses/mit-license.php

Copyright (c) 2005-2017 the SQLAlchemy authors and contributors <see AUTHORS file>.
SQLAlchemy is a trademark of Michael Bayer.

Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ def plus_callback(result):
* exec_task_on_alice.py
```python
# -*- encoding: utf-8 -*-
from crossover import Client, build_callback
from crossover import Client
from bob import plus_callback

alice_broker = "redis://localhost:6379/0"
alice_client = Client(broker=alice_broker)

alice_client.plus(x=340, y=210, callback=build_callback(plus_callback))
alice_client.plus(x=340, y=210, callback=plus_callback)

```

7 changes: 4 additions & 3 deletions crossover/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- encoding: utf-8 -*-
import celery
import posixpath
from celery.utils.log import get_task_logger
from kombu import Exchange, Queue

Expand Down Expand Up @@ -34,7 +33,7 @@ def register_router(celery_app):
celery_app.conf.task_queues = [queue]


def build_callback(task):
def _build_callback(task):
return {
'broker': task.app.conf.broker_url,
'task': task.name
Expand All @@ -61,11 +60,13 @@ def __call__(self, *args, **kwargs):

class _Requester(object):
def __init__(self, broker, remote_task_name, task=CROSSOVER_ROUTER_NAME, queue=CROSSOVER_QUEUE):
self.url = "{0}/{1}".format(broker, posixpath.join(task, queue))
self.url = "{0}/{1}#{2}".format(broker, task, queue)
self.remote_task_name = remote_task_name

def __call__(self, *args, **kwargs):
kwargs['task_name'] = self.remote_task_name
if 'callback' in kwargs:
kwargs['callback'] = _build_callback(kwargs['callback'])
requests.post(self.url, json=kwargs)


Expand Down
4 changes: 2 additions & 2 deletions examples/project_2/call_p1_add.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- encoding: utf-8 -*-
from crossover import Client, build_callback
from crossover import Client
from examples.project_2.project import plus_callback

p1_broker = "redis://localhost:6379/0"
project_1_client = Client(broker=p1_broker)

project_1_client.plus(x=340, y=210, callback=build_callback(plus_callback))
project_1_client.plus(x=340, y=210, callback=plus_callback)
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
celery[redis]==4.1.0
-e git+https://github.com/debonzi/requests-celery-adapter@783b6e17deb1fc61c0ac85fdb34c56b040ed9c71#egg=rca
requests-celery-adapters==2.0.1
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[metadata]
description-file = README.md
21 changes: 18 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,26 @@

from setuptools import setup

setup(name='Celery Crossover',
version='1.0',
description='Celery Crossover',
requires = [
'celery[redis]==4.1.0',
'requests-celery-adapters==2.0.4',
'six>=1.11.0'
]

extras_require = {
'test': [
'pytest>=3.2.2'
],
}


setup(name='celery-crossover',
version='1.0.0',
description='Celery Crossover aims to make it really easy to execute tasks in another service.',
author='Daniel Debonzi',
author_email='[email protected]',
install_requires=requires,
extras_require=extras_require,
url='https://github.com/debonzi/celery_crossover',
packages=['crossover', 'examples'],
)

0 comments on commit 7a66f13

Please sign in to comment.