Revert "grpc-js-core: support propagation cancellation"

This reverts commit 8a31711431071084a3ad972b122a27653fe78be2.
This commit is contained in:
Kelvin Jin 2018-01-25 11:26:02 -08:00
parent 5bd0386d8d
commit b31f345c8d
4 changed files with 5 additions and 34 deletions

View File

@ -19,6 +19,8 @@ export interface CallStreamOptions {
flags: number;
}
export type CallOptions = Partial<CallStreamOptions>;
export interface StatusObject {
code: Status;
details: string;

View File

@ -3,26 +3,16 @@ import * as http2 from 'http2';
import {checkServerIdentity, SecureContext, PeerCertificate} from 'tls';
import * as url from 'url';
import {Call} from './call';
import {CallCredentials} from './call-credentials';
import {CallCredentialsFilterFactory} from './call-credentials-filter';
import {CallStream, CallStreamOptions, Http2CallStream} from './call-stream';
import {CallOptions, CallStream, CallStreamOptions, Http2CallStream} from './call-stream';
import {ChannelCredentials} from './channel-credentials';
import {CompressionFilterFactory} from './compression-filter';
import {EmitterAugmentation0} from './events';
import {Status} from './constants';
import {DeadlineFilterFactory} from './deadline-filter';
import {FilterStackFactory} from './filter-stack';
import {Metadata, MetadataObject} from './metadata';
import { MetadataStatusFilterFactory } from './metadata-status-filter';
import { PropagateFlags } from './index';
export type CallOptions = {
// Represents a parent server call.
// For our purposes we only need to know of the 'cancelled' event.
parent?: EmitterAugmentation0<'cancelled'> & EventEmitter;
propagate_flags?: number;
} & Partial<CallStreamOptions>;
const IDLE_TIMEOUT_MS = 300000;
@ -259,19 +249,6 @@ export class Http2Channel extends EventEmitter implements Channel {
let stream: Http2CallStream =
new Http2CallStream(methodName, finalOptions, this.filterStackFactory);
this.startHttp2Stream(methodName, stream, metadata);
// handle propagation flags
const propagateFlags = typeof options.propagate_flags === 'number' ?
options.propagate_flags : PropagateFlags.DEFAULTS;
if (options.parent) {
// TODO(kjin): Implement other propagation flags.
if (propagateFlags & PropagateFlags.CANCELLATION) {
options.parent.on('cancelled', () => {
stream.cancelWithStatus(Status.CANCELLED, 'Cancellation propagated from parent call');
});
}
}
return stream;
}

View File

@ -2,8 +2,8 @@ import {once} from 'lodash';
import {URL} from 'url';
import {ClientDuplexStream, ClientDuplexStreamImpl, ClientReadableStream, ClientReadableStreamImpl, ClientUnaryCall, ClientUnaryCallImpl, ClientWritableStream, ClientWritableStreamImpl, ServiceError} from './call';
import {CallStream, StatusObject, WriteObject} from './call-stream';
import {CallOptions, Channel, ChannelOptions, Http2Channel} from './channel';
import {CallOptions, CallStream, StatusObject, WriteObject} from './call-stream';
import {Channel, ChannelOptions, Http2Channel} from './channel';
import {ChannelCredentials} from './channel-credentials';
import {Status} from './constants';
import {Metadata} from './metadata';

View File

@ -17,11 +17,3 @@ export enum Status {
DATA_LOSS,
UNAUTHENTICATED
}
export enum PropagateFlags {
DEADLINE = 1,
CENSUS_STATS_CONTEXT = 2,
CENSUS_TRACING_CONTEXT = 4,
CANCELLATION = 8,
DEFAULTS = 65535
}