Sync docs from master to gh-pages
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
<html><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>4. Function Catalog and Flexible Function Signatures</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="multi_spring-cloud-function.html" title="Spring Cloud Function"><link rel="up" href="multi_spring-cloud-function.html" title="Spring Cloud Function"><link rel="prev" href="multi__building_and_running_a_function.html" title="3. Building and Running a Function"><link rel="next" href="multi__standalone_web_applications.html" title="5. Standalone Web Applications"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">4. Function Catalog and Flexible Function Signatures</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__building_and_running_a_function.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="multi__standalone_web_applications.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="_function_catalog_and_flexible_function_signatures" href="#_function_catalog_and_flexible_function_signatures"></a>4. Function Catalog and Flexible Function Signatures</h1></div></div></div><p>One of the main features of Spring Cloud Function is to adapt and
|
||||
support a range of type signatures for user-defined functions. So
|
||||
users can supply a bean of type <code class="literal">Function<String,String></code>, for
|
||||
instance, and the <code class="literal">FunctionCatalog</code> will wrap it into a
|
||||
<code class="literal">Function<Flux<String>,Flux<String>></code>. Users don’t normally have to
|
||||
care about the <code class="literal">FunctionCatalog</code> at all, but it is useful to know what
|
||||
kind of functions are supported in user code.</p><p>Generally speaking users can expect that if they write a function for
|
||||
<title>4. Function Catalog and Flexible Function Signatures</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="multi_spring-cloud-function.html" title="Spring Cloud Function"><link rel="up" href="multi_spring-cloud-function.html" title="Spring Cloud Function"><link rel="prev" href="multi__building_and_running_a_function.html" title="3. Building and Running a Function"><link rel="next" href="multi__standalone_web_applications.html" title="5. Standalone Web Applications"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">4. Function Catalog and Flexible Function Signatures</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__building_and_running_a_function.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="multi__standalone_web_applications.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="_function_catalog_and_flexible_function_signatures" href="#_function_catalog_and_flexible_function_signatures"></a>4. Function Catalog and Flexible Function Signatures</h1></div></div></div><p>One of the main features of Spring Cloud Function is to adapt and support a range of type signatures for user-defined functions,
|
||||
while providing a consistent execution model.
|
||||
That’s why all user defined functions are transformed into a canonical representation by <code class="literal">FunctionCatalog</code>, using primitives
|
||||
defined by the <a class="link" href="https://projectreactor.io/" target="_top">Project Reactor</a> (i.e., <code class="literal">Flux<T></code> and <code class="literal">Mono<T></code>).
|
||||
Users can supply a bean of type <code class="literal">Function<String,String></code>, for instance, and the <code class="literal">FunctionCatalog</code> will wrap it into a
|
||||
<code class="literal">Function<Flux<String>,Flux<String>></code>.</p><p>Using Reactor based primitives not only helps with the canonical representation of user defined functions, but it also
|
||||
facilitates a more robust and flexible(reactive) execution model.</p><p>While users don’t normally have to care about the <code class="literal">FunctionCatalog</code> at all, it is useful to know what
|
||||
kind of functions are supported in user code.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_java_8_function_support" href="#_java_8_function_support"></a>4.1 Java 8 function support</h2></div></div></div><p>Generally speaking users can expect that if they write a function for
|
||||
a plain old Java type (or primitive wrapper), then the function
|
||||
catalog will wrap it to a <code class="literal">Flux</code> of the same type. If the user writes
|
||||
a function using <code class="literal">Message</code> (from spring-messaging) it will receive and
|
||||
@@ -17,10 +18,21 @@ need to write <code class="literal">Consumer<Flux<?>></code>, but if
|
||||
remember to subscribe to the input flux. If you declare a <code class="literal">Consumer</code>
|
||||
of a non publisher type (which is normal), it will be converted to a
|
||||
function that returns a publisher, so that it can be subscribed to in
|
||||
a controlled way.</p><p>A function catalog can contain a <code class="literal">Supplier</code> and a <code class="literal">Function</code> (or
|
||||
<code class="literal">Consumer</code>) with the same name (like a GET and a POST to the same
|
||||
resource). It can even contain a <code class="literal">Consumer<Flux<>></code> with the same name
|
||||
as a <code class="literal">Function</code>, but it cannot contain a <code class="literal">Consumer<T></code> and a
|
||||
<code class="literal">Function<T,S></code> with the same name when <code class="literal">T</code> is not a <code class="literal">Publisher</code>
|
||||
because the consumer would be converted to a <code class="literal">Function</code> and only one
|
||||
of them can be registered.</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__building_and_running_a_function.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="multi__standalone_web_applications.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">3. Building and Running a Function </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud-function.html">Home</a></td><td width="40%" align="right" valign="top"> 5. Standalone Web Applications</td></tr></table></div></body></html>
|
||||
a controlled way.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_kotlin_lambda_support" href="#_kotlin_lambda_support"></a>4.2 Kotlin Lambda support</h2></div></div></div><p>We also provide support for Kotlin lambdas (since v2.0).
|
||||
Consider the following:</p><pre class="programlisting"><em><span class="hl-annotation" style="color: gray">@Bean</span></em>
|
||||
open fun kotlinSupplier(): () -> String {
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> { <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"Hello from Kotlin"</span> }
|
||||
}
|
||||
|
||||
<em><span class="hl-annotation" style="color: gray">@Bean</span></em>
|
||||
open fun kotlinFunction(): (String) -> String {
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> { it.toUpperCase() }
|
||||
}
|
||||
|
||||
<em><span class="hl-annotation" style="color: gray">@Bean</span></em>
|
||||
open fun kotlinConsumer(): (String) -> Unit {
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> { println(it) }
|
||||
}</pre><p>The above represents Kotlin lambdas configured as Spring beans. The signature of each maps to a Java equivalent of
|
||||
<code class="literal">Supplier</code>, <code class="literal">Function</code> and <code class="literal">Consumer</code>, and thus supported/recognized signatures by the framework.
|
||||
While mechanics of Kotlin-to-Java mapping are outside of the scope of this documentation, it is important to understand that the
|
||||
same rules for signature transformation outlined in "Java 8 function support" section are applied here as well.</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__building_and_running_a_function.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="multi__standalone_web_applications.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">3. Building and Running a Function </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud-function.html">Home</a></td><td width="40%" align="right" valign="top"> 5. Standalone Web Applications</td></tr></table></div></body></html>
|
||||
@@ -1,3 +1,3 @@
|
||||
<html><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>Spring Cloud Function</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="multi_spring-cloud-function.html" title="Spring Cloud Function"><link rel="next" href="multi_pr01.html" title=""></head><body class="firstpage" bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Spring Cloud Function</th></tr><tr><td width="20%" align="left"> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="multi_pr01.html">Next</a></td></tr></table><hr></div><div lang="en" class="book"><div class="titlepage"><div><div><h1 class="title"><a name="d0e3"></a>Spring Cloud Function</h1></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="preface"><a href="multi_pr01.html"></a></span></dt><dt><span class="chapter"><a href="multi__introduction.html">1. Introduction</a></span></dt><dt><span class="chapter"><a href="multi__getting_started.html">2. Getting Started</a></span></dt><dt><span class="chapter"><a href="multi__building_and_running_a_function.html">3. Building and Running a Function</a></span></dt><dt><span class="chapter"><a href="multi__function_catalog_and_flexible_function_signatures.html">4. Function Catalog and Flexible Function Signatures</a></span></dt><dt><span class="chapter"><a href="multi__standalone_web_applications.html">5. Standalone Web Applications</a></span></dt><dt><span class="chapter"><a href="multi__standalone_streaming_applications.html">6. Standalone Streaming Applications</a></span></dt><dt><span class="chapter"><a href="multi__deploying_a_packaged_function.html">7. Deploying a Packaged Function</a></span></dt><dt><span class="chapter"><a href="multi__dynamic_compilation.html">8. Dynamic Compilation</a></span></dt><dt><span class="chapter"><a href="multi__serverless_platform_adapters.html">9. Serverless Platform Adapters</a></span></dt><dd><dl><dt><span class="section"><a href="multi__serverless_platform_adapters.html#_aws_lambda">9.1. AWS Lambda</a></span></dt><dd><dl><dt><span class="section"><a href="multi__serverless_platform_adapters.html#_introduction_2">9.1.1. Introduction</a></span></dt><dt><span class="section"><a href="multi__serverless_platform_adapters.html#_notes_on_jar_layout">9.1.2. Notes on JAR Layout</a></span></dt><dt><span class="section"><a href="multi__serverless_platform_adapters.html#_upload">9.1.3. Upload</a></span></dt><dt><span class="section"><a href="multi__serverless_platform_adapters.html#_platfom_specific_features">9.1.4. Platfom Specific Features</a></span></dt><dd><dl><dt><span class="section"><a href="multi__serverless_platform_adapters.html#_http_and_api_gateway">HTTP and API Gateway</a></span></dt></dl></dd></dl></dd><dt><span class="section"><a href="multi__serverless_platform_adapters.html#_azure_functions">9.2. Azure Functions</a></span></dt><dd><dl><dt><span class="section"><a href="multi__serverless_platform_adapters.html#_notes_on_jar_layout_2">9.2.1. Notes on JAR Layout</a></span></dt><dt><span class="section"><a href="multi__serverless_platform_adapters.html#_json_configuration">9.2.2. JSON Configuration</a></span></dt><dt><span class="section"><a href="multi__serverless_platform_adapters.html#_build">9.2.3. Build</a></span></dt><dt><span class="section"><a href="multi__serverless_platform_adapters.html#_running_the_sample">9.2.4. Running the sample</a></span></dt></dl></dd><dt><span class="section"><a href="multi__serverless_platform_adapters.html#_apache_openwhisk">9.3. Apache Openwhisk</a></span></dt><dd><dl><dt><span class="section"><a href="multi__serverless_platform_adapters.html#_quick_start">9.3.1. Quick Start</a></span></dt></dl></dd></dl></dd></dl></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="multi_pr01.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"> </td><td width="20%" align="center"> </td><td width="40%" align="right" valign="top"> </td></tr></table></div></body></html>
|
||||
<title>Spring Cloud Function</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="multi_spring-cloud-function.html" title="Spring Cloud Function"><link rel="next" href="multi_pr01.html" title=""></head><body class="firstpage" bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Spring Cloud Function</th></tr><tr><td width="20%" align="left"> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="multi_pr01.html">Next</a></td></tr></table><hr></div><div lang="en" class="book"><div class="titlepage"><div><div><h1 class="title"><a name="d0e3"></a>Spring Cloud Function</h1></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="preface"><a href="multi_pr01.html"></a></span></dt><dt><span class="chapter"><a href="multi__introduction.html">1. Introduction</a></span></dt><dt><span class="chapter"><a href="multi__getting_started.html">2. Getting Started</a></span></dt><dt><span class="chapter"><a href="multi__building_and_running_a_function.html">3. Building and Running a Function</a></span></dt><dt><span class="chapter"><a href="multi__function_catalog_and_flexible_function_signatures.html">4. Function Catalog and Flexible Function Signatures</a></span></dt><dd><dl><dt><span class="section"><a href="multi__function_catalog_and_flexible_function_signatures.html#_java_8_function_support">4.1. Java 8 function support</a></span></dt><dt><span class="section"><a href="multi__function_catalog_and_flexible_function_signatures.html#_kotlin_lambda_support">4.2. Kotlin Lambda support</a></span></dt></dl></dd><dt><span class="chapter"><a href="multi__standalone_web_applications.html">5. Standalone Web Applications</a></span></dt><dt><span class="chapter"><a href="multi__standalone_streaming_applications.html">6. Standalone Streaming Applications</a></span></dt><dt><span class="chapter"><a href="multi__deploying_a_packaged_function.html">7. Deploying a Packaged Function</a></span></dt><dt><span class="chapter"><a href="multi__dynamic_compilation.html">8. Dynamic Compilation</a></span></dt><dt><span class="chapter"><a href="multi__serverless_platform_adapters.html">9. Serverless Platform Adapters</a></span></dt><dd><dl><dt><span class="section"><a href="multi__serverless_platform_adapters.html#_aws_lambda">9.1. AWS Lambda</a></span></dt><dd><dl><dt><span class="section"><a href="multi__serverless_platform_adapters.html#_introduction_2">9.1.1. Introduction</a></span></dt><dt><span class="section"><a href="multi__serverless_platform_adapters.html#_notes_on_jar_layout">9.1.2. Notes on JAR Layout</a></span></dt><dt><span class="section"><a href="multi__serverless_platform_adapters.html#_upload">9.1.3. Upload</a></span></dt><dt><span class="section"><a href="multi__serverless_platform_adapters.html#_platfom_specific_features">9.1.4. Platfom Specific Features</a></span></dt><dd><dl><dt><span class="section"><a href="multi__serverless_platform_adapters.html#_http_and_api_gateway">HTTP and API Gateway</a></span></dt></dl></dd></dl></dd><dt><span class="section"><a href="multi__serverless_platform_adapters.html#_azure_functions">9.2. Azure Functions</a></span></dt><dd><dl><dt><span class="section"><a href="multi__serverless_platform_adapters.html#_notes_on_jar_layout_2">9.2.1. Notes on JAR Layout</a></span></dt><dt><span class="section"><a href="multi__serverless_platform_adapters.html#_json_configuration">9.2.2. JSON Configuration</a></span></dt><dt><span class="section"><a href="multi__serverless_platform_adapters.html#_build">9.2.3. Build</a></span></dt><dt><span class="section"><a href="multi__serverless_platform_adapters.html#_running_the_sample">9.2.4. Running the sample</a></span></dt></dl></dd><dt><span class="section"><a href="multi__serverless_platform_adapters.html#_apache_openwhisk">9.3. Apache Openwhisk</a></span></dt><dd><dl><dt><span class="section"><a href="multi__serverless_platform_adapters.html#_quick_start">9.3.1. Quick Start</a></span></dt></dl></dd></dl></dd></dl></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="multi_pr01.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"> </td><td width="20%" align="center"> </td><td width="40%" align="right" valign="top"> </td></tr></table></div></body></html>
|
||||
Reference in New Issue
Block a user