now has possibility to end streaming requests
This commit is contained in:
parent
56612f9ac9
commit
6a8751afd2
@ -43,6 +43,7 @@ release:
|
||||
- priv
|
||||
|
||||
trigger:
|
||||
image: hosttoday/ht-docker-node:npmts
|
||||
stage: trigger
|
||||
script:
|
||||
- npmci trigger
|
||||
|
2
dist/dockersock.classes.dockersock.d.ts
vendored
2
dist/dockersock.classes.dockersock.d.ts
vendored
@ -4,6 +4,7 @@ import * as plugins from "./dockersock.plugins";
|
||||
import { Observable } from "rxjs";
|
||||
export declare class Dockersock {
|
||||
sockPath: string;
|
||||
requestObjectmap: plugins.lik.Objectmap;
|
||||
constructor(pathArg?: string);
|
||||
auth(userArg: string, passArg: string): plugins.q.Promise<{}>;
|
||||
listContainers(): plugins.q.Promise<{}>;
|
||||
@ -23,4 +24,5 @@ export declare class Dockersock {
|
||||
getChangeObservable(): Observable<{}>;
|
||||
request(methodArg: string, routeArg: string, queryArg?: string, dataArg?: {}): plugins.q.Promise<{}>;
|
||||
requestStream(methodArg: string, routeArg: string, queryArg?: string, dataArg?: {}): plugins.q.Promise<{}>;
|
||||
endRequests(): void;
|
||||
}
|
||||
|
16
dist/dockersock.classes.dockersock.js
vendored
16
dist/dockersock.classes.dockersock.js
vendored
File diff suppressed because one or more lines are too long
1
dist/dockersock.plugins.d.ts
vendored
1
dist/dockersock.plugins.d.ts
vendored
@ -1,5 +1,6 @@
|
||||
import "typings-global";
|
||||
export import beautylog = require("beautylog");
|
||||
export import lik = require("lik");
|
||||
export import q = require("q");
|
||||
export import request = require("request");
|
||||
export import rxjs = require("rxjs");
|
||||
|
3
dist/dockersock.plugins.js
vendored
3
dist/dockersock.plugins.js
vendored
@ -1,7 +1,8 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
exports.beautylog = require("beautylog");
|
||||
exports.lik = require("lik");
|
||||
exports.q = require("q");
|
||||
exports.request = require("request");
|
||||
exports.rxjs = require("rxjs");
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZG9ja2Vyc29jay5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvZG9ja2Vyc29jay5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDVixpQkFBUyxXQUFXLFdBQVcsQ0FBQyxDQUFDO0FBQ2pDLFNBQUMsV0FBVyxHQUFHLENBQUMsQ0FBQztBQUNqQixlQUFPLFdBQVcsU0FBUyxDQUFDLENBQUM7QUFDN0IsWUFBSSxXQUFXLE1BQU0sQ0FBQyxDQUFDIn0=
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZG9ja2Vyc29jay5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvZG9ja2Vyc29jay5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDVixpQkFBUyxXQUFXLFdBQVcsQ0FBQyxDQUFDO0FBQ2pDLFdBQUcsV0FBVyxLQUFLLENBQUMsQ0FBQztBQUNyQixTQUFDLFdBQVcsR0FBRyxDQUFDLENBQUM7QUFDakIsZUFBTyxXQUFXLFNBQVMsQ0FBQyxDQUFDO0FBQzdCLFlBQUksV0FBVyxNQUFNLENBQUMsQ0FBQyJ9
|
@ -27,15 +27,16 @@
|
||||
"dependencies": {
|
||||
"@types/q": "^0.0.27",
|
||||
"@types/request": "^0.0.27",
|
||||
"beautylog": "^5.0.14",
|
||||
"beautylog": "^5.0.18",
|
||||
"lik": "^1.0.7",
|
||||
"q": "^1.4.1",
|
||||
"request": "^2.73.0",
|
||||
"request": "^2.74.0",
|
||||
"rxjs": "^5.0.0-beta.10",
|
||||
"typings-global": "^1.0.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"npmts-g": "^5.2.6",
|
||||
"should": "^9.0.2",
|
||||
"npmts-g": "^5.2.8",
|
||||
"should": "^10.0.0",
|
||||
"typings-test": "^1.0.1"
|
||||
}
|
||||
}
|
||||
|
12
test/test.js
12
test/test.js
@ -29,8 +29,16 @@ describe("dockersock", function () {
|
||||
testDockersock.pullImage("hosttoday/ht-docker-dbase")
|
||||
.then((dataArg) => {
|
||||
done();
|
||||
}, done);
|
||||
});
|
||||
});
|
||||
it("should return a change Objservable", function (done) {
|
||||
this.timeout(10000);
|
||||
testDockersock.getChangeObservable();
|
||||
setTimeout(() => {
|
||||
testDockersock.endRequests();
|
||||
done();
|
||||
}, 5000);
|
||||
});
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsUUFBTyxRQUFRLENBQUMsQ0FBQTtBQUVoQix3QkFBeUIsZUFFekIsQ0FBQyxDQUZ1QztBQUV4QyxRQUFRLENBQUMsWUFBWSxFQUFDO0lBQ2xCLFFBQVEsQ0FBQyxlQUFlLEVBQUM7UUFDckIsSUFBSSxjQUF5QixDQUFDO1FBQzlCLEVBQUUsQ0FBQyx5Q0FBeUMsRUFBQztZQUN6QyxjQUFjLEdBQUcsSUFBSSxrQkFBVSxFQUFFLENBQUM7WUFDbEMsY0FBYyxDQUFDLE1BQU0sQ0FBQyxFQUFFLENBQUMsVUFBVSxDQUFDLGtCQUFVLENBQUMsQ0FBQztRQUNwRCxDQUFDLENBQUMsQ0FBQztRQUNILEVBQUUsQ0FBQyx3QkFBd0IsRUFBQyxVQUFTLElBQUk7WUFDckMsY0FBYyxDQUFDLGNBQWMsRUFBRTtpQkFDMUIsSUFBSSxDQUFDLENBQUMsT0FBT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JQUFJLENBQUMsQ0FBQyxPQUFPO2dCQUNWLElBQUksRUFBRSxDQUFDO1lBQ1gsQ0FBQyxDQUFDLENBQUM7UUFDWCxDQUFDLENBQUMsQ0FBQztRQUNILEVBQUUsQ0FBQyxvQ0FBb0MsRUFBQyxVQUFTLElBQUk7WUFDakQsSUFBSSxDQUFDLE9BQU8sQ0FBQyxLQUFLLENBQUMsQ0FBQztZQUNwQixjQUFjLENBQUMsbUJBQW1CLEVBQUUsQ0FBQztZQUNyQyxVQUFVLENBQUM7Z0JBQ1AsY0FBYyxDQUFDLFdBQVcsRUFBRSxDQUFDO2dCQUM3QixJQUFJLEVBQUUsQ0FBQztZQUNYLENBQUMsRUFBQyxJQUFJLENBQUMsQ0FBQztRQUNaLENBQUMsQ0FBQyxDQUFBO0lBQ04sQ0FBQyxDQUFDLENBQUM7QUFDUCxDQUFDLENBQUMsQ0FBQyJ9
|
10
test/test.ts
10
test/test.ts
@ -30,7 +30,15 @@ describe("dockersock",function(){
|
||||
testDockersock.pullImage("hosttoday/ht-docker-dbase")
|
||||
.then((dataArg)=>{
|
||||
done();
|
||||
},done);
|
||||
});
|
||||
});
|
||||
it("should return a change Objservable",function(done){
|
||||
this.timeout(10000);
|
||||
testDockersock.getChangeObservable();
|
||||
setTimeout(() => {
|
||||
testDockersock.endRequests();
|
||||
done();
|
||||
},5000);
|
||||
})
|
||||
});
|
||||
});
|
@ -4,6 +4,7 @@ import {Observable} from "rxjs";
|
||||
|
||||
export class Dockersock {
|
||||
sockPath: string;
|
||||
requestObjectmap: plugins.lik.Objectmap = new plugins.lik.Objectmap();
|
||||
constructor(pathArg: string = "http://unix:/var/run/docker.sock:") {
|
||||
this.sockPath = pathArg;
|
||||
}
|
||||
@ -137,6 +138,7 @@ export class Dockersock {
|
||||
};
|
||||
});
|
||||
requestStream.on("response", (response) => {
|
||||
this.requestObjectmap.add(response);
|
||||
if (response.statusCode == 200) {
|
||||
plugins.beautylog.ok("request returned status 200, so we are good!");
|
||||
} else {
|
||||
@ -145,6 +147,7 @@ export class Dockersock {
|
||||
});
|
||||
let changeObservable = Observable.fromEvent(requestStream, "data");
|
||||
requestStream.on("end", () => {
|
||||
this.requestObjectmap.remove(requestStream);
|
||||
});
|
||||
return changeObservable;
|
||||
}
|
||||
@ -198,6 +201,7 @@ export class Dockersock {
|
||||
};
|
||||
});
|
||||
requestStream.on("response", (response) => {
|
||||
this.requestObjectmap.add(response);
|
||||
if (response.statusCode == 200) {
|
||||
plugins.beautylog.ok("request returned status 200, so we are good!");
|
||||
} else {
|
||||
@ -210,6 +214,15 @@ export class Dockersock {
|
||||
status = JSON.parse(data.toString()).status;
|
||||
plugins.beautylog.logReduced(status);
|
||||
});
|
||||
requestStream.on("end", () => {
|
||||
this.requestObjectmap.remove(requestStream);
|
||||
});
|
||||
return done.promise;
|
||||
}
|
||||
};
|
||||
endRequests() {
|
||||
this.requestObjectmap.forEach((itemArg: plugins.request.Request) => {
|
||||
itemArg.emit("end");
|
||||
});
|
||||
this.requestObjectmap.wipe();
|
||||
};
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
import "typings-global";
|
||||
export import beautylog = require("beautylog");
|
||||
export import lik = require("lik");
|
||||
export import q = require("q");
|
||||
export import request = require("request");
|
||||
export import rxjs = require("rxjs");
|
Loading…
Reference in New Issue
Block a user