Skip to content

Commit a999ab3

Browse files
committed
Rename await to awaitOutput
1 parent 5e61761 commit a999ab3

File tree

3 files changed

+16
-33
lines changed

3 files changed

+16
-33
lines changed

modal-js/src/function.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class Function_ {
6969
let retryCount = 0;
7070
while (true) {
7171
try {
72-
return await invocation.await();
72+
return await invocation.awaitOutput();
7373
} catch (err) {
7474
if (err instanceof InternalFailure && retryCount <= maxSystemRetries) {
7575
await invocation.retry(retryCount);

modal-js/src/function_call.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class FunctionCall {
3737
const invocation = ControlPlaneInvocation.fromFunctionCallId(
3838
this.functionCallId,
3939
);
40-
return invocation.await(timeout);
40+
return invocation.awaitOutput(timeout);
4141
}
4242

4343
/** Cancel a running function call. */

modal-js/src/invocation.ts

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
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
*/
2625
export 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

121104
function timeNowSeconds() {

0 commit comments

Comments
 (0)