Node正文(Body)
The body of a FunctionNode set through FunctionNode.Builder.body. A Java body is blocking code, so it does not run on the dispatcher of the coroutine that collects the run: it runs on the dispatcher passed to FunctionNodes, by default a view of Dispatchers.IO without its thread limit, so it may block, for example to wait for a child, without stalling the workflow. A waiting body holds its thread: the default starts one thread per body that waits at the same time, and a dispatcher an app passes needs a free thread for every such body, so a single-threaded or small bounded one can hang the run. Bound a fan-out with the maxParallelWorkers of parallelOf, or pass a bounded dispatcher when bodies wait for nothing.
Cancelling the node, for example on its timeout, interrupts the thread and waits for the body to return. A body that ignores the interrupt, or waits in join(), keeps the node, its timeout and the run going until it returns. A CancellationException the body throws without such a cancel fails the node. A failure wrapped in a CompletionException or ExecutionException, as join() and get() throw, fails the node with its cause, which error events and RetryConfig name, so a child's pause from InteropContextView.runNode makes the node wait. input arrives as the node's input type, in JSON form on an untyped port (a whole number as a Long, a fraction as a Double, an object as a Map), or as a Content message, and may be a predecessor's own collection, so the body must not mutate it.
Return null for no output, a value of the output type, or an Event to emit as it is (an Event with content sends a message, and an output goes in the return value, not in the Event), and ask the user with requestInput. A body rerun after a pause runs from the top again.