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

dgraph-js-ws

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dgraph-js-ws - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

1

lib/response.d.ts
export interface ResponsePayload {
id?: string;
error?: string;

@@ -3,0 +4,0 @@ message?: string;

50

lib/txn.js

@@ -20,2 +20,3 @@ "use strict";

const operators_1 = require("rxjs/operators");
const uniqid_1 = __importDefault(require("uniqid"));
const response_1 = require("./response");

@@ -46,3 +47,3 @@ const log = debug_1.default('dgraph-js-ws:txn');

const request = {
id: short.generate(),
id: uniqid_1.default(),
query: {

@@ -53,3 +54,3 @@ q,

};
this.logger.log(JSON.stringify(request));
log(JSON.stringify(request));
return this.sendRequest(request);

@@ -62,6 +63,6 @@ });

const request = {
id: short.generate(),
id: uniqid_1.default(),
mutate: mu.getPayload(),
};
this.logger.log(JSON.stringify(request));
log(JSON.stringify(request));
return this.sendRequest(request);

@@ -74,3 +75,3 @@ });

const request = {
id: short.generate(),
id: uniqid_1.default(),
query: {

@@ -82,3 +83,3 @@ q,

};
this.logger.log(JSON.stringify(request));
log(JSON.stringify(request));
return this.sendRequest(request);

@@ -91,6 +92,6 @@ });

const request = {
id: short.generate(),
id: uniqid_1.default(),
commit: true,
};
this.logger.log(JSON.stringify(request));
log(JSON.stringify(request));
return this.sendRequest(request);

@@ -102,3 +103,3 @@ });

yield this.waitUntilConnected();
this.logger.debug('discarding');
log('discarding');
this.ws.close();

@@ -111,4 +112,4 @@ return Promise.resolve(new response_1.Response({}));

this.messageSubject
.pipe(operators_1.map(data => data.toString()), operators_1.tap(dataString => this.logger.log(`{"requestId": "${request.id}", "response": ${dataString}}`)), operators_1.map(dataString => JSON.parse(dataString)), operators_1.filter(response => response.id === request.id), operators_1.take(1))
.subscribe(payload => {
.pipe(operators_1.map((data) => data.toString()), operators_1.tap((dataString) => log(`{"requestId": "${request.id}", "response": ${dataString}}`)), operators_1.map((dataString) => JSON.parse(dataString)), operators_1.filter((response) => response.id === request.id), operators_1.take(1))
.subscribe((payload) => {
if (payload.error) {

@@ -120,4 +121,4 @@ reject(new Error(payload.error));

}
}, e => {
this.logger.error(e);
}, (e) => {
log(e);
reject(e);

@@ -147,3 +148,3 @@ });

this.ws.on('open', () => {
this.logger.debug(`connected to ${this.address}`);
log(`connected to ${this.address}`);
this.connectedSubject.next(true);

@@ -153,3 +154,3 @@ this.startHeartbeat();

this.ws.on('close', () => {
this.logger.debug(`disconnected`);
log(`disconnected`);
this.connectedSubject.next(false);

@@ -159,3 +160,3 @@ this.cleanup();

this.ws.on('message', (data) => {
this.logger.verbose('decrement query count');
log('decrement query count');
this.queryCount -= 1;

@@ -165,11 +166,10 @@ this.messageSubject.next(data);

this.ws.on('pong', () => {
this.logger.verbose('got heartbeat');
log('got heartbeat');
});
this.ws.on('error', err => {
this.logger.error(err);
this.ws.on('error', (err) => {
log(err);
});
this.startHeartbeat();
}
cleanup() {
this.logger.debug('cleanup');
log('cleanup');
this.ws.removeAllListeners();

@@ -179,10 +179,10 @@ this.killHeartbeat();

startHeartbeat() {
this.logger.verbose('starting heartbeat');
log('starting heartbeat');
this.heartbeatTask = setInterval(() => {
if (this.queryCount > 0) {
this.logger.verbose(`sending heartbeat, query count ${this.queryCount}`);
log(`sending heartbeat, query count ${this.queryCount}`);
this.ws.ping();
}
else {
this.logger.verbose('skipping heartbeat since no active requests');
log('skipping heartbeat since no active requests');
}

@@ -192,3 +192,3 @@ }, 3000);

killHeartbeat() {
this.logger.verbose('killing heartbeat');
log('killing heartbeat');
clearInterval(this.heartbeatTask);

@@ -195,0 +195,0 @@ }

{
"name": "dgraph-js-ws",
"version": "0.2.0",
"version": "0.2.1",
"description": "dGraph JS WebSocket Client",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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