Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

kafka-avro

Package Overview
Dependencies
Maintainers
2
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kafka-avro - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

16

lib/kafka-avro.js

@@ -56,2 +56,5 @@ /*

/** @type {boolean} Whether the producer should fail when no schema was found. */
this._shouldFailWhenSchemaIsMissing = opts.shouldFailWhenSchemaIsMissing === true;
/** @type {Array.<node-rdkafka.Producer>} Instanciated producers. */

@@ -123,6 +126,13 @@ this._producers = [];

return Promise.all(disconnectPromises)
.then( () => {
if(this.sr._refreshHandle)
clearInterval(this.sr._refreshHandle);
.then( () => {
if(this.sr._refreshHandle)
clearInterval(this.sr._refreshHandle);
});
});
/**
* @param {boolean} shouldFail Whether the producer should fail when no schema was found.
*/
KafkaAvro.prototype.setShouldFailWhenSchemaIsMissing = function(shouldFail) {
this.__shouldFailWhenSchemaIsMissing = shouldFail;
};

@@ -85,2 +85,8 @@ /**

if (this.__shouldFailWhenSchemaIsMissing) {
throw new Error(
'Unable to serialize message for topic ' + topicName
+ ' and type ' + schemaType + ': schema not found');
}
return (typeof data === 'object')

@@ -109,3 +115,3 @@ ? new Buffer(JSON.stringify(data))

Producer.prototype._produceWrapper = function (producerInstance, topicName,
partition, value, key, timestamp, optOpaque) {
partition, value, key, timestamp, optOpaque) {
var sendKey = key

@@ -112,0 +118,0 @@ ? this._serializeType(topicName, true, key)

2

package.json
{
"name": "kafka-avro",
"version": "1.2.0",
"version": "1.2.1",
"main": "./lib/kafka-avro",

@@ -5,0 +5,0 @@ "description": "Node.js bindings for librdkafka with Avro schema serialization.",

@@ -68,2 +68,3 @@ # kafka-avro

* `httpsAgent` **Object** initialized [https Agent class](https://nodejs.org/api/https.html#https_class_https_agent)
* `shouldFailWhenSchemaIsMissing` **Boolean** Set to true if producing a message for which no AVRO schema can be found should throw an error

@@ -278,2 +279,4 @@ ### Producer

## Release History
- **1.2.1**, *06 Sep 2019*
- Adds a new the optional config param `shouldFailWhenSchemaIsMissing` to let the producer fail when no schema could be found (instead of producing as JSON) (by [bfncs](https://github.com/bfncs))
- **1.2.0**, *03 March 2019*

@@ -280,0 +283,0 @@ - Fixed cases when both key and value schemas were available, but the value was being serialized using the key schema (by [macabu](https://github.com/macabu))

@@ -116,3 +116,14 @@ /**

});
it('should fail when schema is missing and shouldFailWhenSchemaIsMissing is set', function() {
var message = {
name: 'Thanasis',
long: 540,
};
this.kafkaAvro.setShouldFailWhenSchemaIsMissing(true);
var binded = this.producer.produce.bind(this.producer, "topic-without-schema", -1, message, 'key');
expect(binded).to.throw(Error);
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc