grpc-server-js
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -6,2 +6,3 @@ 'use strict'; | ||
const { StreamDecoder } = require('./stream-decoder'); | ||
const { hasGrpcStatusCode } = require('./utils'); | ||
const kCall = Symbol('call'); | ||
@@ -23,2 +24,3 @@ const kReadableState = Symbol('readableState'); | ||
ServerUnaryCall.prototype.getPeer = getPeer; | ||
ServerUnaryCall.prototype.getDeadline = getDeadline; | ||
@@ -61,2 +63,3 @@ | ||
ServerReadableStream.prototype.getPeer = getPeer; | ||
ServerReadableStream.prototype.getDeadline = getDeadline; | ||
ServerReadableStream.prototype[kReadablePushOrBufferMessage] = | ||
@@ -121,2 +124,3 @@ readablePushOrBufferMessage; | ||
ServerWritableStream.prototype.getPeer = getPeer; | ||
ServerWritableStream.prototype.getDeadline = getDeadline; | ||
@@ -135,2 +139,3 @@ | ||
ServerDuplexStream.prototype.getPeer = getPeer; | ||
ServerDuplexStream.prototype.getDeadline = getDeadline; | ||
ServerDuplexStream.prototype._read = ServerReadableStream.prototype._read; | ||
@@ -170,2 +175,7 @@ ServerDuplexStream.prototype._write = ServerWritableStream.prototype._write; | ||
function getDeadline () { | ||
return this[kCall].deadline; | ||
} | ||
function setUpHandler (handler, call, metadata) { | ||
@@ -274,3 +284,6 @@ handler[kCall] = call; | ||
err.code = Status.INTERNAL; | ||
if (!hasGrpcStatusCode(err)) { | ||
err.code = Status.INTERNAL; | ||
} | ||
this.emit('error', err); | ||
@@ -277,0 +290,0 @@ } |
@@ -6,2 +6,5 @@ /// <reference types="node" /> | ||
export type Deadline = Date | number; | ||
export interface Serialize<T> { | ||
@@ -121,2 +124,3 @@ (value: T): Buffer; | ||
sendMetadata(responseMetadata: Metadata): void; | ||
getDeadline(): Deadline; | ||
}; | ||
@@ -194,2 +198,3 @@ export declare type ServerUnaryCall<RequestType, ResponseType> = | ||
implementation: UntypedServiceImplementation): void; | ||
removeService(service: ServiceDefinition): void; | ||
bind(port: string, creds: ServerCredentials): Promise<void>; | ||
@@ -207,2 +212,3 @@ bindAsync(port: string, | ||
): boolean; | ||
unregister(name: string): boolean; | ||
start(): void; | ||
@@ -209,0 +215,0 @@ tryShutdown(callback: (error?: Error) => void): void; |
@@ -36,3 +36,4 @@ 'use strict'; | ||
this.cancelled = false; | ||
this.deadline = null; | ||
this.deadline = Infinity; | ||
this.deadlineTimer = null; | ||
this.compression = new CompressionFilter(); | ||
@@ -92,3 +93,4 @@ this.metadataSent = false; | ||
this.deadline = setTimeout(handleExpiredDeadline, timeout, this); | ||
this.deadline = Date.now() + timeout; | ||
this.deadlineTimer = setTimeout(handleExpiredDeadline, timeout, this); | ||
metadata.remove(kGrpcTimeoutHeader); | ||
@@ -252,3 +254,3 @@ } | ||
clearTimeout(this.deadline); | ||
clearTimeout(this.deadlineTimer); | ||
this.stream.sendTrailers(trailersToSend); | ||
@@ -255,0 +257,0 @@ } |
@@ -32,3 +32,6 @@ 'use strict'; | ||
} = Http2.constants; | ||
const defaultHttp2Settings = Http2.getDefaultSettings(); | ||
const defaultHttp2Settings = { | ||
...Http2.getDefaultSettings(), | ||
maxSendHeaderBlockLength: Number.MAX_SAFE_INTEGER | ||
}; | ||
@@ -154,6 +157,2 @@ const unsuportedMediaTypeResponse = { | ||
addService (service, implementation) { | ||
if (this[kStarted] === true) { | ||
throw new Error('Can\'t add a service to a started server.'); | ||
} | ||
if (service === null || typeof service !== 'object' || | ||
@@ -206,2 +205,12 @@ implementation === null || typeof implementation !== 'object') { | ||
removeService (service) { | ||
if (service === null || typeof service !== 'object') { | ||
throw new Error('removeService requires an object argument'); | ||
} | ||
Object.keys(service).forEach((name) => { | ||
this.unregister(service[name].path); | ||
}); | ||
} | ||
register (name, handler, serialize, deserialize, type) { | ||
@@ -223,2 +232,6 @@ if (this[kHandlers].has(name)) { | ||
unregister (name) { | ||
return this[kHandlers].delete(name); | ||
} | ||
tryShutdown (callback) { | ||
@@ -225,0 +238,0 @@ callback = typeof callback === 'function' ? callback : noop; |
{ | ||
"name": "grpc-server-js", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Pure JavaScript gRPC Server", | ||
@@ -30,3 +30,3 @@ "author": "Colin J. Ihrig <cjihrig@gmail.com> (http://www.cjihrig.com/)", | ||
"cb-barrier": "1.x.x", | ||
"@hapi/lab": "23.x.x" | ||
"@hapi/lab": "24.x.x" | ||
}, | ||
@@ -33,0 +33,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
60088
18
1686