Comments (5)
It would have to be POST for both, because they're both destructive operations.
from zenqueue.
Very good point.
from zenqueue.
Great work on the HTTP support. Would it be possible to set it up so a single server can talk both protocols, on two different ports? HTTP makes more sense for submitting jobs to a queue, but the regular socket+JSON protocol feels like a better bet for workers that are consuming the jobs. Running them as separate servers won't work because the queue itself is in-memory and only available to one server at a time.
from zenqueue.
There are two ways to go about doing this. One of them is the ‘easy’ way, the other is a ‘cool’ way.
The easy way is: you write a Python script that looks like the following:
from eventlet import coros
from zenqueue.queue import Queue
from zenqueue.server import QueueServer
def main():
queue = Queue(mode='async')
# QueueServer accepts an optional `queue` parameter which, if provided,
# will be served by the server.
http_server = QueueServer(method='http', queue=queue)
native_server = QueueServer(method='native', queue=queue)
# Run each of the servers on a pool, so that we can `wait_all()` for them to
# finish.
pool = coros.CoroutinePool()
pool.execute_async(http_server.serve, interface='0.0.0.0', port=3080)
pool.execute_async(native_server.serve, interface='0.0.0.0', port=3000)
pool.wait_all()
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
pass
The cool way is to run the native server separately, and then use a Python script like this:
from zenqueue.client import QueueClient
from zenqueue.server import QueueServer
def main():
client = QueueClient(method='native', host='127.0.0.1', port=3000)
# Because the client's interface matches exactly that of the `Queue()`, we can
# pass it to the `QueueServer()` constructor as if it were a queue.
server = QueueServer(method='http', queue=client)
server.serve(interface='0.0.0.0', port=3080)
if __name__ == '__main__':
main()
from zenqueue.
Very neat. Might be worth adding to the official documentation, but I love the code samples. zenqueue is a very elegant design.
from zenqueue.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zenqueue.