Inverted Json is a job server which helps you to organize RPC, MQ, PubSub communication between clients and workers. It helps to save time and resources.
Memory usage, CPU usage, Multi-core result
Here we:
docker run -it -p 8001:8001 lega911/ijson
# 1. a worker requests for a command (task) "test/command"
curl localhost:8001/test/command -H 'type: get'
# 2. a client invokes the command
curl localhost:8001/test/command -d '{"id": 123, "params": "test data"}'
# the worker receives {"id": 123, "params": "test data"}
# 3. and sends response with the same id
curl localhost:8001 -H 'type: result' -d '{"id": 123, "result": "data received"}'
# client receives {"id": 123, "result": "data received"}
response = requests.post('http://127.0.0.1:8001/test/command', json={'id': 1, 'params': 'Hello'})
print(response.json())
while True:
# get a request
request = requests.post('http://127.0.0.1:8001/test/command', headers={'Type': 'get'}).json()
# send a response
response = {
'id': request['id'],
'result': request['params'] + ' world!'
}
requests.post('http://127.0.0.1:8001/', json=response, headers={'Type': 'result'})