This commit is contained in:
Kelvin Jin 2017-08-02 17:11:35 -07:00
parent 7e32e84bca
commit 3995a13d22
7 changed files with 68 additions and 3 deletions

View File

@ -1 +1,15 @@
export class CallCredentials {}
import { Metadata } from './metadata'
export class CallCredentials {
static createFromMetadataGenerator(metadataGenerator: (options: Object, cb: (err: Error, metadata: Metadata) => void) => void): CallCredentials {
throw new Error();
}
call(options: Object, cb: (err: Error, metadata: Metadata) => void): void {
throw new Error();
}
compose(callCredentials: CallCredentials): CallCredentials {
throw new Error();
}
}

17
src/call.ts Normal file
View File

@ -0,0 +1,17 @@
import * as events from 'events';
import * as stream from 'stream';
const { EventEmitter } = events;
const { Readable, Writable, Duplex } = stream;
export interface Call {
// cancel();
// getPeer();
}
export class ClientUnaryCall extends EventEmitter implements Call {}
export class ClientReadableStream extends Readable implements Call {}
export class ClientWritableStream extends Writable implements Call {}
export class ClientDuplexStream extends Duplex implements Call {}

View File

@ -1,4 +1,5 @@
import { CallCredentials } from './call-credentials';
import { SecureContext } from 'tls'; // or whatever it's actually called
/**
* A class that contains credentials for communicating over a channel.
@ -17,4 +18,12 @@ export class ChannelCredentials {
compose(callCredentials: CallCredentials) : ChannelCredentials {
throw new Error();
}
getCallCredentials() : CallCredentials {
throw new Error();
}
getSecureContext() : SecureContext {
throw new Error();
}
}

View File

@ -7,6 +7,10 @@ import { Metadata } from './metadata';
*/
export interface ChannelOptions {}
export class SubChannel {}
// todo: maybe we want an interface for load balancing, but no implementation for anything complicated
/**
* A class that represents a communication channel to a server specified by a given address.
*/

19
src/client.ts Normal file
View File

@ -0,0 +1,19 @@
import { ClientUnaryCall } from './call'
import { Metadata } from './metadata'
export interface CallOptions {}
export class Client {
makeUnaryRequest<RequestType, ResponseType>(
method: string,
serialize: (value: RequestType) => Buffer,
deserialize: (value: Buffer) => ResponseType,
argument: RequestType,
metadata?: Metadata,
options?: CallOptions,
callback?: (err?: Error, value?: ResponseType) => void
): ClientUnaryCall {
throw new Error();
}
// TODO: Do for other method types and overloads
}

View File

@ -1 +1,3 @@
export class Metadata {}
export class Metadata {
}

View File

@ -1,5 +1,5 @@
{
"extends": "node_modules/google-ts-style/tsconfig-google.json",
"extends": "./node_modules/google-ts-style/tsconfig-google.json",
"include": [
"src/*.ts",
"src/**/*.ts",