Babex
is a modern solution for communications between microservices.
Input message:
{
"data": Any,
"chain": [Path],
"config": Any
}
Where Path
like:
{
"exchange": String,
"key": String,
"isMultiple": Bool,
"successful": Bool
}
Service example Sum(a, b)
:
Request:
{
"data": {
"a": 2,
"b": 3
},
"chain": [
{
"exchange": "math",
"key": "sum",
"isMultiple": false,
"successful": false
},
{
"exchange": "math",
"key": "sum.next",
"isMultiple": false,
"successful": false
}
],
"config": null
}
import babex
exchange = 'math'
routing_key = 'sum'
name = 'math.sum'
address = "amqp://localhost"
service = babex.new_service(name=name, address=address)
service.bind_to_exchange(exchange, routing_key)
service.listen(lambda message: service.next(message, {"c": message.data["a"] + message.data["b"]}))
Result:
{
"data": {
"c": 5
},
"chain": [
{
"exchange": "math",
"key": "sum",
"isMultiple": false,
"successful": true
},
{
"exchange": "math",
"key": "sum.next",
"isMultiple": false,
"successful": false
}
],
"config": null
}
- Golang - https://github.com/matroskin13/babex
- Node.js - https://github.com/spyzhov/babex-node