Skip to content

Commit 7e12a66

Browse files
authored
Define a generic interface to allow flexibility (#160)
* Define a generic interface to allow flexibility * Add intercepting call * Remove export * Use the grpc interface inside the factory * closer match to design doc
1 parent db52df9 commit 7e12a66

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/grpc_interface.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export interface GrpcInterface {
2+
Channel: any;
3+
connectivityState: any;
4+
status: any;
5+
InterceptingCall: any;
6+
};

src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*
1717
*/
1818
import * as grpcType from '@grpc/grpc-js';
19+
import {GrpcInterface} from './grpc_interface';
1920
import * as util from 'util';
2021

2122
import {ChannelRef} from './channel_ref';
@@ -30,7 +31,8 @@ import AffinityConfig = protoRoot.grpc.gcp.AffinityConfig;
3031

3132
type GrpcModule = typeof grpcType;
3233

33-
export = (grpc: GrpcModule) => {
34+
export = (grpc: GrpcInterface) => setup(grpc as GrpcModule);
35+
const setup = (grpc: GrpcModule) => {
3436
const GcpChannelFactory = getGcpChannelFactoryClass(grpc);
3537
/**
3638
* Create ApiConfig proto message from config object.

0 commit comments

Comments
 (0)