kafkajs-stream
Advanced tools
Comparing version 0.0.11 to 0.0.12
@@ -5,2 +5,9 @@ # Changelog | ||
### [0.0.12](https://github.com/kambing86/kafkajs-stream/compare/v0.0.11...v0.0.12) (2020-06-27) | ||
### Features | ||
* add runConfig for ConsumerStream ([76ab099](https://github.com/kambing86/kafkajs-stream/commit/76ab099b969ce7e2fe49f11315475c4bd1006806)) | ||
### [0.0.11](https://github.com/kambing86/kafkajs-stream/compare/v0.0.10...v0.0.11) (2020-01-07) | ||
@@ -7,0 +14,0 @@ |
/// <reference types="node" /> | ||
import { ConsumerConfig, Kafka, KafkaMessage } from 'kafkajs'; | ||
import { Readable } from 'stream'; | ||
import { ConsumerConfig, Kafka, KafkaMessage } from "kafkajs"; | ||
import { Readable } from "stream"; | ||
interface ConsumerObjectStreamOptions { | ||
@@ -5,0 +5,0 @@ config?: ConsumerConfig; |
@@ -12,2 +12,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ConsumerObjectStream = void 0; | ||
const stream_1 = require("stream"); | ||
@@ -17,3 +18,3 @@ class ConsumerObjectStream extends stream_1.Readable { | ||
var _a; | ||
super({ objectMode: true, highWaterMark: (_a = options.highWaterMark, (_a !== null && _a !== void 0 ? _a : 512)) }); | ||
super({ objectMode: true, highWaterMark: (_a = options.highWaterMark) !== null && _a !== void 0 ? _a : 512 }); | ||
this.onCrash = (err) => __awaiter(this, void 0, void 0, function* () { | ||
@@ -52,3 +53,3 @@ console.error(err); | ||
} | ||
this.consumer.on('consumer.crash', this.onCrash); | ||
this.consumer.on("consumer.crash", this.onCrash); | ||
} | ||
@@ -77,3 +78,3 @@ if (!this.started) { | ||
} | ||
const payload = (_c = (_b = (_a = this.options).transform) === null || _b === void 0 ? void 0 : _b.call(_a, message), (_c !== null && _c !== void 0 ? _c : message)); | ||
const payload = (_c = (_b = (_a = this.options).transform) === null || _b === void 0 ? void 0 : _b.call(_a, message)) !== null && _c !== void 0 ? _c : message; | ||
const continueToPush = this.push(payload); | ||
@@ -80,0 +81,0 @@ resolveOffset(message.offset); |
/// <reference types="node" /> | ||
import { ConsumerConfig, Kafka } from 'kafkajs'; | ||
import { Readable } from 'stream'; | ||
import { ConsumerConfig, ConsumerRunConfig, Kafka } from "kafkajs"; | ||
import { Readable } from "stream"; | ||
export declare class ConsumerStream extends Readable { | ||
constructor(kafka: Kafka, options: { | ||
config?: ConsumerConfig; | ||
runConfig?: ConsumerRunConfig; | ||
topic: { | ||
@@ -15,2 +16,3 @@ topic: string; | ||
private config?; | ||
private runConfig?; | ||
private topic; | ||
@@ -17,0 +19,0 @@ private connected; |
@@ -12,2 +12,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ConsumerStream = void 0; | ||
const stream_1 = require("stream"); | ||
@@ -24,2 +25,3 @@ class ConsumerStream extends stream_1.Readable { | ||
this.config = options.config; | ||
this.runConfig = options.runConfig; | ||
this.topic = options.topic; | ||
@@ -50,3 +52,3 @@ this.init(); | ||
yield this.consumer.subscribe(this.topic); | ||
this.consumer.on('consumer.crash', this.onCrash); | ||
this.consumer.on("consumer.crash", this.onCrash); | ||
} | ||
@@ -64,5 +66,3 @@ if (!this.started) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield this.consumer.run({ | ||
eachBatchAutoResolve: false, | ||
eachBatch: ({ batch, resolveOffset, heartbeat }) => __awaiter(this, void 0, void 0, function* () { | ||
yield this.consumer.run(Object.assign({ eachBatchAutoResolve: false, eachBatch: ({ batch, resolveOffset, heartbeat }) => __awaiter(this, void 0, void 0, function* () { | ||
if (this.paused) { | ||
@@ -82,4 +82,3 @@ return; | ||
} | ||
}), | ||
}); | ||
}) }, this.runConfig)); | ||
}); | ||
@@ -86,0 +85,0 @@ } |
@@ -1,4 +0,4 @@ | ||
export { ConsumerObjectStream } from './ConsumerObjectStream'; | ||
export { ConsumerStream } from './ConsumerStream'; | ||
export { ProducerObjectStream } from './ProducerObjectStream'; | ||
export { ProducerStream } from './ProducerStream'; | ||
export { ConsumerObjectStream } from "./ConsumerObjectStream"; | ||
export { ConsumerStream } from "./ConsumerStream"; | ||
export { ProducerObjectStream } from "./ProducerObjectStream"; | ||
export { ProducerStream } from "./ProducerStream"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var ConsumerObjectStream_1 = require("./ConsumerObjectStream"); | ||
exports.ConsumerObjectStream = ConsumerObjectStream_1.ConsumerObjectStream; | ||
Object.defineProperty(exports, "ConsumerObjectStream", { enumerable: true, get: function () { return ConsumerObjectStream_1.ConsumerObjectStream; } }); | ||
var ConsumerStream_1 = require("./ConsumerStream"); | ||
exports.ConsumerStream = ConsumerStream_1.ConsumerStream; | ||
Object.defineProperty(exports, "ConsumerStream", { enumerable: true, get: function () { return ConsumerStream_1.ConsumerStream; } }); | ||
var ProducerObjectStream_1 = require("./ProducerObjectStream"); | ||
exports.ProducerObjectStream = ProducerObjectStream_1.ProducerObjectStream; | ||
Object.defineProperty(exports, "ProducerObjectStream", { enumerable: true, get: function () { return ProducerObjectStream_1.ProducerObjectStream; } }); | ||
var ProducerStream_1 = require("./ProducerStream"); | ||
exports.ProducerStream = ProducerStream_1.ProducerStream; | ||
Object.defineProperty(exports, "ProducerStream", { enumerable: true, get: function () { return ProducerStream_1.ProducerStream; } }); | ||
//# sourceMappingURL=index.js.map |
/// <reference types="node" /> | ||
import { CompressionTypes, Kafka, Message, ProducerConfig } from 'kafkajs'; | ||
import { Writable } from 'stream'; | ||
import { CompressionTypes, Kafka, Message, ProducerConfig } from "kafkajs"; | ||
import { Writable } from "stream"; | ||
interface ProducerObjectStreamOptions { | ||
@@ -5,0 +5,0 @@ config?: ProducerConfig; |
@@ -12,2 +12,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ProducerObjectStream = void 0; | ||
const stream_1 = require("stream"); | ||
@@ -17,3 +18,3 @@ class ProducerObjectStream extends stream_1.Writable { | ||
var _a; | ||
super({ objectMode: true, highWaterMark: (_a = options.highWaterMark, (_a !== null && _a !== void 0 ? _a : 512)) }); | ||
super({ objectMode: true, highWaterMark: (_a = options.highWaterMark) !== null && _a !== void 0 ? _a : 512 }); | ||
this.producer = kafka.producer(options.config); | ||
@@ -32,3 +33,3 @@ this.options = options; | ||
topic: this.options.topic, | ||
messages: chunks.map(({ chunk }) => { var _a, _b, _c; return _c = (_b = (_a = this.options).transform) === null || _b === void 0 ? void 0 : _b.call(_a, chunk), (_c !== null && _c !== void 0 ? _c : chunk); }), | ||
messages: chunks.map(({ chunk }) => { var _a, _b, _c; return (_c = (_b = (_a = this.options).transform) === null || _b === void 0 ? void 0 : _b.call(_a, chunk)) !== null && _c !== void 0 ? _c : chunk; }), | ||
acks: this.options.acks, | ||
@@ -35,0 +36,0 @@ timeout: this.options.timeout, |
/// <reference types="node" /> | ||
import { CompressionTypes, Kafka, ProducerConfig } from 'kafkajs'; | ||
import { Writable } from 'stream'; | ||
import { CompressionTypes, Kafka, ProducerConfig } from "kafkajs"; | ||
import { Writable } from "stream"; | ||
export declare class ProducerStream extends Writable { | ||
@@ -14,3 +14,3 @@ constructor(kafka: Kafka, options: { | ||
private connected; | ||
write(value: Uint8Array | Buffer | string, encoding?: string | ((error: Error | null | undefined) => void), callback?: (error: Error | null | undefined) => void): boolean; | ||
write(value: Uint8Array | Buffer | string, encoding?: BufferEncoding | ((error: Error | null | undefined) => void), callback?: (error: Error | null | undefined) => void): boolean; | ||
_writev(chunks: { | ||
@@ -17,0 +17,0 @@ chunk: Uint8Array | Buffer | string; |
@@ -12,2 +12,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ProducerStream = void 0; | ||
const stream_1 = require("stream"); | ||
@@ -26,3 +27,3 @@ class ProducerStream extends stream_1.Writable { | ||
} | ||
if (typeof encoding === 'string') { | ||
if (typeof encoding === "string") { | ||
return super.write(value, encoding, callback); | ||
@@ -29,0 +30,0 @@ } |
/// <reference types="node" /> | ||
import { ConsumerConfig, Kafka, KafkaMessage } from 'kafkajs'; | ||
import { Readable } from 'stream'; | ||
import { ConsumerConfig, Kafka, KafkaMessage } from "kafkajs"; | ||
import { Readable } from "stream"; | ||
interface ConsumerObjectStreamOptions { | ||
@@ -5,0 +5,0 @@ config?: ConsumerConfig; |
@@ -1,2 +0,2 @@ | ||
import { Readable } from 'stream'; | ||
import { Readable } from "stream"; | ||
export class ConsumerObjectStream extends Readable { | ||
@@ -37,3 +37,3 @@ constructor(kafka, options) { | ||
} | ||
this.consumer.on('consumer.crash', this.onCrash); | ||
this.consumer.on("consumer.crash", this.onCrash); | ||
} | ||
@@ -40,0 +40,0 @@ if (!this.started) { |
/// <reference types="node" /> | ||
import { ConsumerConfig, Kafka } from 'kafkajs'; | ||
import { Readable } from 'stream'; | ||
import { ConsumerConfig, ConsumerRunConfig, Kafka } from "kafkajs"; | ||
import { Readable } from "stream"; | ||
export declare class ConsumerStream extends Readable { | ||
constructor(kafka: Kafka, options: { | ||
config?: ConsumerConfig; | ||
runConfig?: ConsumerRunConfig; | ||
topic: { | ||
@@ -15,2 +16,3 @@ topic: string; | ||
private config?; | ||
private runConfig?; | ||
private topic; | ||
@@ -17,0 +19,0 @@ private connected; |
@@ -1,2 +0,2 @@ | ||
import { Readable } from 'stream'; | ||
import { Readable } from "stream"; | ||
export class ConsumerStream extends Readable { | ||
@@ -12,2 +12,3 @@ constructor(kafka, options) { | ||
this.config = options.config; | ||
this.runConfig = options.runConfig; | ||
this.topic = options.topic; | ||
@@ -37,3 +38,3 @@ this.init(); | ||
await this.consumer.subscribe(this.topic); | ||
this.consumer.on('consumer.crash', this.onCrash); | ||
this.consumer.on("consumer.crash", this.onCrash); | ||
} | ||
@@ -67,2 +68,3 @@ if (!this.started) { | ||
}, | ||
...this.runConfig, | ||
}); | ||
@@ -69,0 +71,0 @@ } |
@@ -1,4 +0,4 @@ | ||
export { ConsumerObjectStream } from './ConsumerObjectStream'; | ||
export { ConsumerStream } from './ConsumerStream'; | ||
export { ProducerObjectStream } from './ProducerObjectStream'; | ||
export { ProducerStream } from './ProducerStream'; | ||
export { ConsumerObjectStream } from "./ConsumerObjectStream"; | ||
export { ConsumerStream } from "./ConsumerStream"; | ||
export { ProducerObjectStream } from "./ProducerObjectStream"; | ||
export { ProducerStream } from "./ProducerStream"; |
@@ -1,5 +0,5 @@ | ||
export { ConsumerObjectStream } from './ConsumerObjectStream'; | ||
export { ConsumerStream } from './ConsumerStream'; | ||
export { ProducerObjectStream } from './ProducerObjectStream'; | ||
export { ProducerStream } from './ProducerStream'; | ||
export { ConsumerObjectStream } from "./ConsumerObjectStream"; | ||
export { ConsumerStream } from "./ConsumerStream"; | ||
export { ProducerObjectStream } from "./ProducerObjectStream"; | ||
export { ProducerStream } from "./ProducerStream"; | ||
//# sourceMappingURL=index.js.map |
/// <reference types="node" /> | ||
import { CompressionTypes, Kafka, Message, ProducerConfig } from 'kafkajs'; | ||
import { Writable } from 'stream'; | ||
import { CompressionTypes, Kafka, Message, ProducerConfig } from "kafkajs"; | ||
import { Writable } from "stream"; | ||
interface ProducerObjectStreamOptions { | ||
@@ -5,0 +5,0 @@ config?: ProducerConfig; |
@@ -1,2 +0,2 @@ | ||
import { Writable } from 'stream'; | ||
import { Writable } from "stream"; | ||
export class ProducerObjectStream extends Writable { | ||
@@ -3,0 +3,0 @@ constructor(kafka, options) { |
/// <reference types="node" /> | ||
import { CompressionTypes, Kafka, ProducerConfig } from 'kafkajs'; | ||
import { Writable } from 'stream'; | ||
import { CompressionTypes, Kafka, ProducerConfig } from "kafkajs"; | ||
import { Writable } from "stream"; | ||
export declare class ProducerStream extends Writable { | ||
@@ -14,3 +14,3 @@ constructor(kafka: Kafka, options: { | ||
private connected; | ||
write(value: Uint8Array | Buffer | string, encoding?: string | ((error: Error | null | undefined) => void), callback?: (error: Error | null | undefined) => void): boolean; | ||
write(value: Uint8Array | Buffer | string, encoding?: BufferEncoding | ((error: Error | null | undefined) => void), callback?: (error: Error | null | undefined) => void): boolean; | ||
_writev(chunks: { | ||
@@ -17,0 +17,0 @@ chunk: Uint8Array | Buffer | string; |
@@ -1,2 +0,2 @@ | ||
import { Writable } from 'stream'; | ||
import { Writable } from "stream"; | ||
export class ProducerStream extends Writable { | ||
@@ -14,3 +14,3 @@ constructor(kafka, options) { | ||
} | ||
if (typeof encoding === 'string') { | ||
if (typeof encoding === "string") { | ||
return super.write(value, encoding, callback); | ||
@@ -17,0 +17,0 @@ } |
{ | ||
"name": "kafkajs-stream", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"description": "Stream for kafkajs", | ||
@@ -13,2 +13,4 @@ "main": "dist/index.js", | ||
"release": "standard-version", | ||
"lint": "tslint 'src/**/*.{j,t}s{,x}' && eslint 'src/**/*.{j,t}s{,x}'", | ||
"lint:fix": "tslint --fix 'src/**/*.{j,t}s{,x}' && eslint --fix 'src/**/*.{j,t}s{,x}'", | ||
"prettier": "prettier --check 'src/**/*.*'", | ||
@@ -36,7 +38,18 @@ "prettier:write": "prettier --write 'src/**/*.*'" | ||
"devDependencies": { | ||
"@types/node": "^13.1.4", | ||
"kafkajs": "^1.11.0", | ||
"@types/node": "^14.0.14", | ||
"@typescript-eslint/eslint-plugin": "^2.15.0", | ||
"@typescript-eslint/eslint-plugin-tslint": "^2.15.0", | ||
"@typescript-eslint/parser": "^2.15.0", | ||
"eslint": "^6.8.0", | ||
"eslint-config-airbnb-base": "^14.0.0", | ||
"eslint-config-prettier": "^6.9.0", | ||
"eslint-plugin-import": "^2.19.1", | ||
"eslint-plugin-prettier": "^3.1.2", | ||
"husky": "^4.0.0", | ||
"kafkajs": "^1.12.0", | ||
"prettier": "^1.19.1", | ||
"standard-version": "^7.0.1", | ||
"typescript": "^3.7.4" | ||
"tslint": "^5.20.1", | ||
"tslint-microsoft-contrib": "^6.2.0", | ||
"typescript": "^3.9.5" | ||
}, | ||
@@ -46,3 +59,8 @@ "files": [ | ||
"module" | ||
] | ||
], | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "yarn lint && yarn prettier" | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
48745
723
16