1.0.2 • Published 7 years ago
loopback-kafka-producer-mixin v1.0.2
loopback-kafka-producer-mixin
Kafka Producer mixin for loopback to add sendEvent method to your models.
INSTALL
npm install loopback-kafka-producer-mixin --save
SERVER CONFIG
Add the mixins
property to your server/model-config.json
:
{
"_meta": {
"sources": [
"loopback/common/models",
"loopback/server/models",
"../common/models",
"./models"
],
"mixins": [
"loopback/common/mixins",
"../node_modules/loopback-kafka-producer-mixin",
"../common/mixins"
]
}
}
MODEL CONFIG
To use with your Models add the mixins
attribute to the definition object of your model config.
{
"name": "Widget",
"properties": {
"name": {
"type": "string",
}
},
"mixins": {
"KafkaProducer" : true
}
}
CONNEXIONS
To be able to connect to your kafka host or zookeeper host, you have to set the KAFKA_URL env variable
export KAFKA_URL=192.168.99.100:2181