robertwb commented on code in PR #29925:
URL: https://github.com/apache/beam/pull/29925#discussion_r1454218768
##########
sdks/typescript/src/apache_beam/worker/operators.ts:
##########
@@ -43,21 +43,22 @@ import {
createSideInputInfo,
} from "./pardo_context";
-// Trying to get some of https://github.com/microsoft/TypeScript/issues/8240
-export const NonPromise = null;
+export const isPromise = (x: any): x is Promise<any> => {
+ return x instanceof Promise;
Review Comment:
In my initial tests this was expensive to do on every element call for every
DoFn, but maybe I was over-optimizing. (There also didn't seem to be a standard
way of checking for promises...maybe that's changed?)
##########
sdks/typescript/src/apache_beam/transforms/pardo.ts:
##########
@@ -51,7 +51,10 @@ export interface DoFn<InputT, OutputT, ContextT = undefined>
{
* now "activated" in the sense that side inputs, metrics, etc. are
* available with runtime values/effects).
*/
- process: (element: InputT, context: ContextT) => Iterable<OutputT> | void;
+ process: (
+ element: InputT,
+ context: ContextT,
+ ) => Iterable<OutputT> | void | Promise<Iterable<OutputT> | void>;
Review Comment:
Is there a reason void is listed twice here?
##########
sdks/typescript/src/apache_beam/worker/operators.ts:
##########
@@ -696,15 +697,15 @@ class GenericParDoOperator implements IOperator {
}
}
- process(wvalue: WindowedValue<unknown>) {
+ async process(wvalue: WindowedValue<unknown>) {
Review Comment:
So even if this doesn't return a promise, it always creates one (and does
the other async overhead), right?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]