FunctionNodes

Creates FunctionNodes from Java with a type per port. Jackson reads each input into its declared type and writes each output as JSON, so records and POJOs work as ports, and a port typed this way infers the schema of that JSON form, or none for a type with no fixed shape or an input Jackson reads as another class through @JsonDeserialize(as = ...) or a builder; Object.class leaves a port untyped, a Content or Event port passes values unchanged, and a String port reads a message as its text, passes null through, rejects any other non-text value, and infers a string schema. An edge into a typed port must fit its schema as between Kotlin ports: the source may write only keys the port type reads, or keys the port type itself writes, with a JSON type that fits (an integer also fits a number), and null only where the port type takes it, such as into a String port or a field marked @Nullable. So a bean fits its own input, even one whose getter and setter names differ by a typo, which then reads null; a creator property that a type never writes fails its own edge, as its reader would get null. A port writes a value as its own class, so a subclass value may write keys its declared type does not; a typed successor skips them, but an explicit input schema with additionalProperties: false rejects them at run time. To run a node on each item of a list, wrap it with FunctionNode.parallelOf.

Numbers, booleans, chars, enums, and text inside a record, also as primitive array elements and map keys, follow the coercion rules of Kotlin ports: a value of the JSON type, the same literal quoted, a whole number into an integer, and one character of text into a char. BigInteger, BigDecimal, the Atomic* types, byte[] (base64) and char[] (text) keep Jackson's readers. A primitive field rejects an explicit null. An enum that Jackson writes as its ordinal, or a boolean it writes as 1 or 0, such as under a numeric @JsonFormat shape, reads back from that number.

Functions

Link copied to clipboard
fun <I, O> builder(inputType: TypeReference<I>, outputType: TypeReference<O>, dispatcher: CoroutineDispatcher = defaultBodyDispatcher): FunctionNode.Builder<I, O>

Like builder with classes, for generic port types such as List<String>.

fun <I, O> builder(inputType: TypeReference<I>, outputType: Class<O & Any>, dispatcher: CoroutineDispatcher = defaultBodyDispatcher): FunctionNode.Builder<I, O>

Like builder with classes, for a generic input type.

fun <I, O> builder(inputType: Class<I & Any>, outputType: TypeReference<O>, dispatcher: CoroutineDispatcher = defaultBodyDispatcher): FunctionNode.Builder<I, O>

Like builder with classes, for a generic output type.

fun <I, O> builder(inputType: Class<I & Any>, outputType: Class<O & Any>, dispatcher: CoroutineDispatcher = defaultBodyDispatcher): FunctionNode.Builder<I, O>

Returns a FunctionNode.Builder whose node reads inputs as inputType and writes outputType outputs as JSON, for setting properties that of does not take. Its body runs on dispatcher, as in of.

Link copied to clipboard
fun <I, O> of(name: String, inputType: TypeReference<I>, outputType: TypeReference<O>, dispatcher: CoroutineDispatcher = defaultBodyDispatcher, body: NodeBody<I, O>): FunctionNode<I, O>

Like of with classes, for generic port types such as List<String>.

fun <I, O> of(name: String, inputType: TypeReference<I>, outputType: Class<O & Any>, dispatcher: CoroutineDispatcher = defaultBodyDispatcher, body: NodeBody<I, O>): FunctionNode<I, O>

Like of with classes, for a generic input type.

fun <I, O> of(name: String, inputType: Class<I & Any>, outputType: TypeReference<O>, dispatcher: CoroutineDispatcher = defaultBodyDispatcher, body: NodeBody<I, O>): FunctionNode<I, O>

Like of with classes, for a generic output type.

fun <I, O> of(name: String, inputType: Class<I & Any>, outputType: Class<O & Any>, dispatcher: CoroutineDispatcher = defaultBodyDispatcher, body: NodeBody<I, O>): FunctionNode<I, O>

Returns a node named name that runs body on each input read as inputType and writes its outputType output as JSON. body runs on a thread of dispatcher, by default of Dispatchers.IO without its thread limit, and may send messages before its output with InteropContextView.emit; see NodeBody:

Link copied to clipboard

Asks the user for input with request and sends its payload as JSON, like the other requestInput overload. For example, build the request with RequestInput.builder to set only a message.

fun <T> requestInput(interruptId: String = Uuid.random(), message: String? = null, payload: Any? = null, responseSchema: Schema? = null): T

Asks the user for input like NodeBody.requestInput, and sends payload as JSON through the same mapper as typed ports, so a record or POJO reaches the client in its JSON form.