File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ export class DgraphClientStub {
1616 mutate ( mu : messages . Mutation ) : Promise < messages . Assigned > ;
1717 commitOrAbort ( ctx : messages . TxnContext ) : Promise < messages . TxnContext > ;
1818 checkVersion ( check : messages . Check ) : Promise < messages . Version > ;
19+ waitForReady ( deadline : grpc . Deadline ) : Promise < void > ;
1920 } ;
2021
2122 constructor ( addr ?: string | null , credentials ?: grpc . ChannelCredentials | null ) {
@@ -35,6 +36,7 @@ export class DgraphClientStub {
3536 mutate : promisify ( this . stub . mutate , this . stub ) ,
3637 commitOrAbort : promisify ( this . stub . commitOrAbort , this . stub ) ,
3738 checkVersion : promisify ( this . stub . checkVersion , this . stub ) ,
39+ waitForReady : promisify ( this . stub . waitForReady , this . stub ) ,
3840 } ;
3941 }
4042
@@ -58,6 +60,10 @@ export class DgraphClientStub {
5860 return this . promisified . checkVersion ( check ) ;
5961 }
6062
63+ public waitForReady ( deadline : grpc . Deadline ) : Promise < void > {
64+ return this . promisified . waitForReady ( deadline ) ;
65+ }
66+
6167 public close ( ) : void {
6268 return this . stub . close ( ) ;
6369 }
Original file line number Diff line number Diff line change 11import * as dgraph from "../src" ;
22
3- import { setup } from "./helper" ;
3+ import { SERVER_ADDR , SERVER_CREDENTIALS , setup } from "./helper" ;
44
55async function checkVersion ( stub : dgraph . DgraphClientStub ) : Promise < void > {
66 const v = await stub . checkVersion ( new dgraph . Check ( ) ) ;
@@ -24,10 +24,17 @@ describe("clientStub", () => {
2424 } ) ;
2525 } ) ;
2626
27+ describe ( "waitForReady" , ( ) => {
28+ it ( "should provide a promisified version of grpc.Client#waitForReady" , async ( ) => {
29+ const clientStub = new dgraph . DgraphClientStub ( SERVER_ADDR , SERVER_CREDENTIALS ) ;
30+ await clientStub . waitForReady ( Date . now ( ) + 500 ) ;
31+ await checkVersion ( clientStub ) ;
32+ } ) ;
33+ } ) ;
34+
2735 describe ( "close" , ( ) => {
2836 it ( "should close channel" , async ( ) => {
29- const client = await setup ( ) ;
30- const clientStub = await client . anyClient ( ) ;
37+ const clientStub = new dgraph . DgraphClientStub ( SERVER_ADDR , SERVER_CREDENTIALS ) ;
3138 clientStub . close ( ) ;
3239 const p = clientStub . checkVersion ( new dgraph . Check ( ) ) ;
3340 await expect ( p ) . rejects . toBeDefined ( ) ;
You can’t perform that action at this time.
0 commit comments