src/bundlingCalls/bundleApiCaller.ts
An implementation of APICaller for bundled calls. Uses BundleExecutor to do bundling.
Properties |
Methods |
constructor(bundler: BundleExecutor)
|
||||||
Defined in src/bundlingCalls/bundleApiCaller.ts:46
|
||||||
Parameters :
|
bundler |
Type : BundleExecutor
|
Defined in src/bundlingCalls/bundleApiCaller.ts:46
|
call | |||||||||||||||
call(apiCall: SimpleCallbackFunction, argument: literal type, settings: CallSettings, status: OngoingCallPromise)
|
|||||||||||||||
Defined in src/bundlingCalls/bundleApiCaller.ts:66
|
|||||||||||||||
Parameters :
Returns :
void
|
fail | |||||||||
fail(canceller: OngoingCallPromise, err: GoogleError)
|
|||||||||
Defined in src/bundlingCalls/bundleApiCaller.ts:82
|
|||||||||
Parameters :
Returns :
void
|
init | |||||||||
init(settings: ApiCallerSettings, callback?: APICallback)
|
|||||||||
Defined in src/bundlingCalls/bundleApiCaller.ts:52
|
|||||||||
Parameters :
Returns :
OngoingCallPromise | OngoingCall
|
result | ||||||
result(canceller: OngoingCallPromise)
|
||||||
Defined in src/bundlingCalls/bundleApiCaller.ts:86
|
||||||
Parameters :
Returns :
any
|
wrap | ||||||
wrap(func: GRPCCall)
|
||||||
Defined in src/bundlingCalls/bundleApiCaller.ts:62
|
||||||
Parameters :
Returns :
GRPCCall
|
import {APICaller, ApiCallerSettings} from '../apiCaller';
import {APICallback, GRPCCall, SimpleCallbackFunction} from '../apitypes';
import {OngoingCall, OngoingCallPromise} from '../call';
import {CallSettings} from '../gax';
import {GoogleError} from '../googleError';
import {BundleExecutor} from './bundleExecutor';
import {TaskCallback} from './task';
/**
* An implementation of APICaller for bundled calls.
* Uses BundleExecutor to do bundling.
*/
export class BundleApiCaller implements APICaller {
bundler: BundleExecutor;
constructor(bundler: BundleExecutor) {
this.bundler = bundler;
}
init(
settings: ApiCallerSettings,
callback?: APICallback
): OngoingCallPromise | OngoingCall {
if (callback) {
return new OngoingCall(callback);
}
return new OngoingCallPromise(settings.promise);
}
wrap(func: GRPCCall): GRPCCall {
return func;
}
call(
apiCall: SimpleCallbackFunction,
argument: {},
settings: CallSettings,
status: OngoingCallPromise
) {
if (!settings.isBundling) {
throw new GoogleError('Bundling enabled with no isBundling!');
}
status.call((argument: {}, callback: TaskCallback) => {
this.bundler.schedule(apiCall, argument, callback);
return status;
}, argument);
}
fail(canceller: OngoingCallPromise, err: GoogleError): void {
canceller.callback!(err);
}
result(canceller: OngoingCallPromise) {
return canceller.promise;
}
}