44 FunctionCallType ,
55 FunctionGetOutputsResponse ,
66 FunctionInput ,
7- FunctionMapResponse ,
87 FunctionRetryInputsItem ,
98 GeneratorDone ,
109 GenericResult ,
@@ -24,12 +23,7 @@ const outputsTimeout = 55 * 1000;
2423 * For now, we support just the control plane, and will add support for the input plane soon.
2524 */
2625export interface Invocation {
27- /**
28- * Spawns the function call asynchronously.
29- * @returns A promise that resolves to the function call ID.
30- */
31- await ( ) : Promise < any > ;
32-
26+ awaitOutput ( timeout ?: number ) : Promise < any > ;
3327 retry ( retryCount : number ) : Promise < void > ;
3428}
3529
@@ -59,11 +53,18 @@ export class ControlPlaneInvocation implements Invocation {
5953 input : FunctionInput ,
6054 invocationType : FunctionCallInvocationType ,
6155 ) {
62- const functionMapResponse = await ControlPlaneInvocation . execFunctionCall (
63- functionId ,
64- input ,
65- invocationType ,
66- ) ;
56+ const functionPutInputsItem = {
57+ idx : 0 ,
58+ input : input ,
59+ } ;
60+
61+ const functionMapResponse = await client . functionMap ( {
62+ functionId : functionId ,
63+ functionCallType : FunctionCallType . FUNCTION_CALL_TYPE_UNARY ,
64+ functionCallInvocationType : invocationType ,
65+ pipelinedInputs : [ functionPutInputsItem ] ,
66+ } ) ;
67+
6768 return new ControlPlaneInvocation (
6869 functionMapResponse . functionCallId ,
6970 input ,
@@ -76,7 +77,7 @@ export class ControlPlaneInvocation implements Invocation {
7677 return new ControlPlaneInvocation ( functionCallId ) ;
7778 }
7879
79- async await ( timeout ?: number ) : Promise < any > {
80+ async awaitOutput ( timeout ?: number ) : Promise < any > {
8081 return await pollControlPlaneForOutput ( this . functionCallId , timeout ) ;
8182 }
8283
@@ -98,24 +99,6 @@ export class ControlPlaneInvocation implements Invocation {
9899 } ) ;
99100 this . inputJwt = functionRetryResponse . inputJwts [ 0 ] ;
100101 }
101-
102- private static async execFunctionCall (
103- functionId : string ,
104- input : FunctionInput ,
105- invocationType : FunctionCallInvocationType ,
106- ) : Promise < FunctionMapResponse > {
107- const functionPutInputsItem = {
108- idx : 0 ,
109- input : input ,
110- } ;
111- // Single input sync invocation
112- return await client . functionMap ( {
113- functionId : functionId ,
114- functionCallType : FunctionCallType . FUNCTION_CALL_TYPE_UNARY ,
115- functionCallInvocationType : invocationType ,
116- pipelinedInputs : [ functionPutInputsItem ] ,
117- } ) ;
118- }
119102}
120103
121104function timeNowSeconds ( ) {
0 commit comments