graphql-kafka-subscriptions
Advanced tools
Comparing version 0.2.6 to 0.3.0
@@ -1,3 +0,2 @@ | ||
/// <reference types="bunyan" /> | ||
import * as Logger from 'bunyan'; | ||
export declare function createChildLogger(logger: Logger, className: string): Logger; |
@@ -1,2 +0,1 @@ | ||
/// <reference types="bunyan" /> | ||
/// <reference types="node" /> | ||
@@ -36,6 +35,6 @@ import { PubSubEngine } from 'graphql-subscriptions'; | ||
asyncIterator<T>(triggers: string | string[]): AsyncIterator<T>; | ||
private onMessage(channel, message); | ||
private onMessage; | ||
brokerList(): any; | ||
private createProducer(topic); | ||
private createConsumer(topic); | ||
private createProducer; | ||
private createConsumer; | ||
} |
@@ -7,6 +7,15 @@ "use strict"; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) | ||
t[p[i]] = s[p[i]]; | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
}; | ||
var __spreadArrays = (this && this.__spreadArrays) || function () { | ||
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; | ||
for (var r = Array(s), k = 0, i = 0; i < il; i++) | ||
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) | ||
r[k] = a[j]; | ||
return r; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -37,3 +46,3 @@ var Kafka = require("node-rdkafka"); | ||
this.subscriptionMap[index] = [channel, onMessage]; | ||
this.channelSubscriptions[channel] = (this.channelSubscriptions[channel] || []).concat([ | ||
this.channelSubscriptions[channel] = __spreadArrays((this.channelSubscriptions[channel] || []), [ | ||
index | ||
@@ -62,7 +71,7 @@ ]); | ||
KafkaPubSub.prototype.brokerList = function () { | ||
return this.options.host.match(',') ? this.options.host : this.options.host + ":" + this.options.port; | ||
return this.options.port ? this.options.host + ":" + this.options.port : this.options.host; | ||
}; | ||
KafkaPubSub.prototype.createProducer = function (topic) { | ||
var _this = this; | ||
var producer = Kafka.Producer.createWriteStream(Object.assign({}, { 'metadata.broker.list': this.brokerList() }, this.options.globalConfig), {}, { topic: topic }); | ||
var producer = Kafka.createWriteStream(Object.assign({}, { 'metadata.broker.list': this.brokerList() }, this.options.globalConfig), {}, { topic: topic }); | ||
producer.on('error', function (err) { | ||
@@ -76,7 +85,7 @@ _this.logger.error(err, 'Error in our kafka stream'); | ||
var groupId = this.options.groupId || Math.ceil(Math.random() * 9999); | ||
var consumer = Kafka.KafkaConsumer.createReadStream(Object.assign({}, { | ||
var stream = Kafka.createReadStream(Object.assign({}, { | ||
'group.id': "kafka-group-" + groupId, | ||
'metadata.broker.list': this.brokerList(), | ||
}, this.options.globalConfig), {}, { topics: [topic] }); | ||
consumer.on('data', function (message) { | ||
stream.consumer.on('data', function (message) { | ||
var parsedMessage = JSON.parse(message.value.toString()); | ||
@@ -91,3 +100,3 @@ if (parsedMessage.channel) { | ||
}); | ||
return consumer; | ||
return stream; | ||
}; | ||
@@ -94,0 +103,0 @@ return KafkaPubSub; |
import { PubSubEngine } from 'graphql-subscriptions/dist/pubsub-engine'; | ||
export declare class PubSubAsyncIterator<T> implements AsyncIterator<T> { | ||
constructor(pubsub: PubSubEngine, eventNames: string | string[]); | ||
next(): Promise<IteratorResult<any>>; | ||
next(): Promise<IteratorResult<any, any>>; | ||
return(): Promise<{ | ||
@@ -16,7 +16,7 @@ value: any; | ||
private pubsub; | ||
private pushValue(message); | ||
private pullValue(); | ||
private emptyQueue(subscriptionIds); | ||
private subscribeAll(); | ||
private unsubscribeAll(subscriptionIds); | ||
private pushValue; | ||
private pullValue; | ||
private emptyQueue; | ||
private subscribeAll; | ||
private unsubscribeAll; | ||
} |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -17,4 +18,4 @@ }); | ||
while (_) try { | ||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [0, t.value]; | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
@@ -21,0 +22,0 @@ case 0: case 1: t = op; break; |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -17,4 +18,4 @@ }); | ||
while (_) try { | ||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [0, t.value]; | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
@@ -38,3 +39,2 @@ case 0: case 1: t = op; break; | ||
}; | ||
var _this = this; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -62,3 +62,3 @@ var index_1 = require("../index"); | ||
}); | ||
it('should subscribe and publish messages correctly', function () { return __awaiter(_this, void 0, void 0, function () { | ||
it('should subscribe and publish messages correctly', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var channel, onMessage, payload, subscription; | ||
@@ -65,0 +65,0 @@ return __generator(this, function (_a) { |
{ | ||
"name": "graphql-kafka-subscriptions", | ||
"version": "0.2.6", | ||
"version": "0.3.0", | ||
"description": "Apollo graphql subscription over Kafka protocol", | ||
@@ -43,15 +43,15 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@types/bunyan": "^1.8.4", | ||
"@types/node": "^9.3.0", | ||
"@types/bunyan": "^1.8.6", | ||
"@types/node": "^12.12.14", | ||
"bunyan": "1.8.12", | ||
"graphql-subscriptions": "^0.5.0", | ||
"iterall": "^1.1.1", | ||
"node-rdkafka": "^2.5.1" | ||
"graphql-subscriptions": "^1.1.0", | ||
"iterall": "^1.2.2", | ||
"node-rdkafka": "^2.7.4" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^21.1.1", | ||
"jest": "^21.2.1", | ||
"ts-jest": "^21.0.1", | ||
"typescript": "^2.5.2" | ||
"@types/jest": "^24.0.23", | ||
"jest": "^24.9.0", | ||
"ts-jest": "^24.2.0", | ||
"typescript": "^3.7.3" | ||
} | ||
} |
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
175443
481
+ Added@types/node@12.20.55(transitive)
+ Addedgraphql@15.10.1(transitive)
+ Addedgraphql-subscriptions@1.2.1(transitive)
- Removed@types/node@9.6.61(transitive)
- Removedgraphql@0.13.2(transitive)
- Removedgraphql-subscriptions@0.5.8(transitive)
Updated@types/bunyan@^1.8.6
Updated@types/node@^12.12.14
Updatedgraphql-subscriptions@^1.1.0
Updatediterall@^1.2.2
Updatednode-rdkafka@^2.7.4