Sync docs from vFinchley.RC2 to gh-pages

This commit is contained in:
Ryan Baxter
2018-05-29 10:16:35 -04:00
parent 91c98f5226
commit 467b983e77
15 changed files with 612 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Part&nbsp;XVI.&nbsp;Appendix: Compendium of Configuration Properties</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.html" title="Spring Cloud"><link rel="up" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="prev" href="multi__building_a_simple_gateway_using_spring_mvc_or_webflux.html" title="117.&nbsp;Building a Simple Gateway Using Spring MVC or Webflux"></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">Part&nbsp;XVI.&nbsp;Appendix: Compendium of Configuration Properties</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__building_a_simple_gateway_using_spring_mvc_or_webflux.html">Prev</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;</td></tr></table><hr></div><div class="part"><div class="titlepage"><div><div><h1 class="title"><a name="_appendix_compendium_of_configuration_properties" href="#_appendix_compendium_of_configuration_properties"></a>Part&nbsp;XVI.&nbsp;Appendix: Compendium of Configuration Properties</h1></div></div></div><div class="partintro"><div></div><div class="informaltable"><table style="border-collapse: collapse;border-top: 0.5pt solid ; border-bottom: 0.5pt solid ; "><colgroup><col class="col_1"><col class="col_2"><col class="col_3"></colgroup><thead><tr><th style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top">Name</th><th style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top">Default</th><th style="border-bottom: 0.5pt solid ; " align="left" valign="top">Description</th></tr></thead><tbody><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>encrypt.fail-on-error</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>true</p></td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Flag to say that a process should fail if there is an encryption or decryption
<title>Part&nbsp;XVII.&nbsp;Appendix: Compendium of Configuration Properties</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.html" title="Spring Cloud"><link rel="up" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="prev" href="multi__deploying_a_packaged_function.html" title="126.&nbsp;Deploying a Packaged Function"></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">Part&nbsp;XVII.&nbsp;Appendix: Compendium of Configuration Properties</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__deploying_a_packaged_function.html">Prev</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;</td></tr></table><hr></div><div class="part"><div class="titlepage"><div><div><h1 class="title"><a name="_appendix_compendium_of_configuration_properties" href="#_appendix_compendium_of_configuration_properties"></a>Part&nbsp;XVII.&nbsp;Appendix: Compendium of Configuration Properties</h1></div></div></div><div class="partintro"><div></div><div class="informaltable"><table style="border-collapse: collapse;border-top: 0.5pt solid ; border-bottom: 0.5pt solid ; "><colgroup><col class="col_1"><col class="col_2"><col class="col_3"></colgroup><thead><tr><th style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top">Name</th><th style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top">Default</th><th style="border-bottom: 0.5pt solid ; " align="left" valign="top">Description</th></tr></thead><tbody><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>encrypt.fail-on-error</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>true</p></td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Flag to say that a process should fail if there is an encryption or decryption
error.</p></td></tr><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>encrypt.key</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top">&nbsp;</td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top"><p>A symmetric key. As a stronger alternative consider using a keystore.</p></td></tr><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>encrypt.key-store.alias</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top">&nbsp;</td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Alias for a key in the store.</p></td></tr><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>encrypt.key-store.location</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top">&nbsp;</td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Location of the key store file, e.g. classpath:/keystore.jks.</p></td></tr><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>encrypt.key-store.password</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top">&nbsp;</td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Password that locks the keystore.</p></td></tr><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>encrypt.key-store.secret</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top">&nbsp;</td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Secret protecting the key (defaults to the same as the password).</p></td></tr><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>encrypt.rsa.algorithm</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top">&nbsp;</td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top"><p>The RSA algorithm to use (DEFAULT or OEAP). Once it is set do not change it (or
existing ciphers will not a decryptable).</p></td></tr><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>encrypt.rsa.salt</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>deadbeef</p></td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Salt for the random secret used to encrypt cipher text. Once it is set do not
change it (or existing ciphers will not a decryptable).</p></td></tr><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>encrypt.rsa.strong</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>false</p></td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Flag to indicate that "strong" AES encryption should be used internally. If
@@ -264,4 +264,4 @@
proxy, so they are sharing authentication data. If using a physical URL outside
your own domain, then generally it would be a bad idea to leak user credentials.</p></td></tr><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>zuul.servlet-path</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>/zuul</p></td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Path to install Zuul as a servlet (not part of Spring MVC). The servlet is more
memory efficient for requests with large bodies, e.g. file uploads.</p></td></tr><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>zuul.ssl-hostname-validation-enabled</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>true</p></td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Flag to say whether the hostname for ssl connections should be verified or not. Default is true.
This should only be used in test setups!</p></td></tr><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>zuul.strip-prefix</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>true</p></td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Flag saying whether to strip the prefix from the path before forwarding.</p></td></tr><tr><td style="border-right: 0.5pt solid ; " align="left" valign="top"><p>zuul.trace-request-body</p></td><td style="border-right: 0.5pt solid ; " align="left" valign="top"><p>true</p></td><td style="" align="left" valign="top"><p>Flag to say that request bodies can be traced.</p></td></tr></tbody></table></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__building_a_simple_gateway_using_spring_mvc_or_webflux.html">Prev</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;</td></tr><tr><td width="40%" align="left" valign="top">117.&nbsp;Building a Simple Gateway Using Spring MVC or Webflux&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;</td></tr></table></div></body></html>
This should only be used in test setups!</p></td></tr><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>zuul.strip-prefix</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>true</p></td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Flag saying whether to strip the prefix from the path before forwarding.</p></td></tr><tr><td style="border-right: 0.5pt solid ; " align="left" valign="top"><p>zuul.trace-request-body</p></td><td style="border-right: 0.5pt solid ; " align="left" valign="top"><p>true</p></td><td style="" align="left" valign="top"><p>Flag to say that request bodies can be traced.</p></td></tr></tbody></table></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__deploying_a_packaged_function.html">Prev</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;</td></tr><tr><td width="40%" align="left" valign="top">126.&nbsp;Deploying a Packaged Function&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;</td></tr></table></div></body></html>

View File

@@ -1,6 +1,6 @@
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>117.&nbsp;Building a Simple Gateway Using Spring MVC or Webflux</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.html" title="Spring Cloud"><link rel="up" href="multi__spring_cloud_gateway.html" title="Part&nbsp;XV.&nbsp;Spring Cloud Gateway"><link rel="prev" href="multi__developer_guide.html" title="116.&nbsp;Developer Guide"><link rel="next" href="multi__appendix_compendium_of_configuration_properties.html" title="Part&nbsp;XVI.&nbsp;Appendix: Compendium of Configuration Properties"></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">117.&nbsp;Building a Simple Gateway Using Spring MVC or Webflux</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__developer_guide.html">Prev</a>&nbsp;</td><th width="60%" align="center">Part&nbsp;XV.&nbsp;Spring Cloud Gateway</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="multi__appendix_compendium_of_configuration_properties.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="_building_a_simple_gateway_using_spring_mvc_or_webflux" href="#_building_a_simple_gateway_using_spring_mvc_or_webflux"></a>117.&nbsp;Building a Simple Gateway Using Spring MVC or Webflux</h2></div></div></div><p>Spring Cloud Gateway provides a utility object called <code class="literal">ProxyExchange</code> which you can use inside a regular Spring web handler as a method parameter. It supports basic downstream HTTP exchanges via methods that mirror the HTTP verbs. With MVC it also supports forwarding to a local handler via the <code class="literal">forward()</code> method. To use the <code class="literal">ProxyExchange</code> just include the right module in your classpath (either <code class="literal">spring-cloud-gateway-mvc</code> or <code class="literal">spring-cloud-gateway-webflux</code>).</p><p>MVC example (proxying a request to "/test" downstream to a remote server):</p><pre class="programlisting"><em><span class="hl-annotation" style="color: gray">@RestController</span></em>
<title>117.&nbsp;Building a Simple Gateway Using Spring MVC or Webflux</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.html" title="Spring Cloud"><link rel="up" href="multi__spring_cloud_gateway.html" title="Part&nbsp;XV.&nbsp;Spring Cloud Gateway"><link rel="prev" href="multi__developer_guide.html" title="116.&nbsp;Developer Guide"><link rel="next" href="multi__spring_cloud_function.html" title="Part&nbsp;XVI.&nbsp;Spring Cloud Function"></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">117.&nbsp;Building a Simple Gateway Using Spring MVC or Webflux</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__developer_guide.html">Prev</a>&nbsp;</td><th width="60%" align="center">Part&nbsp;XV.&nbsp;Spring Cloud Gateway</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="multi__spring_cloud_function.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="_building_a_simple_gateway_using_spring_mvc_or_webflux" href="#_building_a_simple_gateway_using_spring_mvc_or_webflux"></a>117.&nbsp;Building a Simple Gateway Using Spring MVC or Webflux</h2></div></div></div><p>Spring Cloud Gateway provides a utility object called <code class="literal">ProxyExchange</code> which you can use inside a regular Spring web handler as a method parameter. It supports basic downstream HTTP exchanges via methods that mirror the HTTP verbs. With MVC it also supports forwarding to a local handler via the <code class="literal">forward()</code> method. To use the <code class="literal">ProxyExchange</code> just include the right module in your classpath (either <code class="literal">spring-cloud-gateway-mvc</code> or <code class="literal">spring-cloud-gateway-webflux</code>).</p><p>MVC example (proxying a request to "/test" downstream to a remote server):</p><pre class="programlisting"><em><span class="hl-annotation" style="color: gray">@RestController</span></em>
<em><span class="hl-annotation" style="color: gray">@SpringBootApplication</span></em>
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span> GatewaySampleApplication {
@@ -28,4 +28,4 @@
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> ResponseEntity&lt;?&gt; proxyPath(ProxyExchange&lt;<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">byte</span>[]&gt; proxy) <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">throws</span> Exception {
String path = proxy.path(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/proxy/path/"</span>);
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> proxy.uri(home.toString() + <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/foos/"</span> + path).get();
}</pre><p>All the features of Spring MVC or Webflux are available to Gateway handler methods. So you can inject request headers and query parameters, for instance, and you can constrain the incoming requests with declarations in the mapping annotation. See the documentation for <code class="literal">@RequestMapping</code> in Spring MVC for more details of those features.</p><p>Headers can be added to the downstream response using the <code class="literal">header()</code> methods on <code class="literal">ProxyExchange</code>.</p><p>You can also manipulate response headers (and anything else you like in the response) by adding a mapper to the <code class="literal">get()</code> etc. method. The mapper is a <code class="literal">Function</code> that takes the incoming <code class="literal">ResponseEntity</code> and converts it to an outgoing one.</p><p>First class support is provided for "sensitive" headers ("cookie" and "authorization" by default) which are not passed downstream, and for "proxy" headers (<code class="literal">x-forwarded-*</code>).</p><p>Unresolved directive in spring-cloud.adoc - include::../../../../gateway/docs/src/main/asciidoc/spring-cloud-function.adoc[]</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__developer_guide.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="multi__spring_cloud_gateway.html">Up</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="multi__appendix_compendium_of_configuration_properties.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">116.&nbsp;Developer Guide&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;Part&nbsp;XVI.&nbsp;Appendix: Compendium of Configuration Properties</td></tr></table></div></body></html>
}</pre><p>All the features of Spring MVC or Webflux are available to Gateway handler methods. So you can inject request headers and query parameters, for instance, and you can constrain the incoming requests with declarations in the mapping annotation. See the documentation for <code class="literal">@RequestMapping</code> in Spring MVC for more details of those features.</p><p>Headers can be added to the downstream response using the <code class="literal">header()</code> methods on <code class="literal">ProxyExchange</code>.</p><p>You can also manipulate response headers (and anything else you like in the response) by adding a mapper to the <code class="literal">get()</code> etc. method. The mapper is a <code class="literal">Function</code> that takes the incoming <code class="literal">ResponseEntity</code> and converts it to an outgoing one.</p><p>First class support is provided for "sensitive" headers ("cookie" and "authorization" by default) which are not passed downstream, and for "proxy" headers (<code class="literal">x-forwarded-*</code>).</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__developer_guide.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="multi__spring_cloud_gateway.html">Up</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="multi__spring_cloud_function.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">116.&nbsp;Developer Guide&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;Part&nbsp;XVI.&nbsp;Spring Cloud Function</td></tr></table></div></body></html>

View File

@@ -0,0 +1,19 @@
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>120.&nbsp;Building and Running a 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.html" title="Spring Cloud"><link rel="up" href="multi__spring_cloud_function.html" title="Part&nbsp;XVI.&nbsp;Spring Cloud Function"><link rel="prev" href="multi__getting_started.html" title="119.&nbsp;Getting Started"><link rel="next" href="multi__dynamic_compilation.html" title="121.&nbsp;Dynamic Compilation"></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">120.&nbsp;Building and Running a Function</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__getting_started.html">Prev</a>&nbsp;</td><th width="60%" align="center">Part&nbsp;XVI.&nbsp;Spring Cloud Function</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="multi__dynamic_compilation.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="_building_and_running_a_function" href="#_building_and_running_a_function"></a>120.&nbsp;Building and Running a Function</h2></div></div></div><p>The sample <code class="literal">@SpringBootApplication</code> above has a function that can be
decorated at runtime by Spring Cloud Function to be an HTTP endpoint,
or a Stream processor, for instance with RabbitMQ, Apache Kafka or
JMS.</p><p>The <code class="literal">@Beans</code> can be <code class="literal">Function</code>, <code class="literal">Consumer</code> or <code class="literal">Supplier</code> (all from
<code class="literal">java.util</code>), and their parametric types can be String or POJO. A
<code class="literal">Function</code> is exposed as a Spring Cloud Stream <code class="literal">Processor</code> if
<code class="literal">spring-cloud-function-stream</code> is on the classpath.
A <code class="literal">Consumer</code> is also exposed as a Stream
<code class="literal">Sink</code> and a <code class="literal">Supplier</code> translates to a Stream <code class="literal">Source</code>.
HTTP endpoints are exposed if the Stream binder is <code class="literal">spring-cloud-stream-binder-servlet</code>.</p><p>Functions can be of <code class="literal">Flux&lt;String&gt;</code> or <code class="literal">Flux&lt;Pojo&gt;</code> and Spring Cloud
Function takes care of converting the data to and from the desired
types, as long as it comes in as plain text or (in the case of the
POJO) JSON. TBD: support for <code class="literal">Flux&lt;Message&lt;Pojo&gt;&gt;</code> and maybe plain
<code class="literal">Pojo</code> types (Fluxes implied and implemented by the framework).</p><p>Functions can be grouped together in a single application, or deployed
one-per-jar. It&#8217;s up to the developer to choose. An app with multiple
functions can be deployed multiple times in different "personalities",
exposing different functions over different physical transports.</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__getting_started.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="multi__spring_cloud_function.html">Up</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="multi__dynamic_compilation.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">119.&nbsp;Getting Started&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;121.&nbsp;Dynamic Compilation</td></tr></table></div></body></html>

View File

@@ -0,0 +1,3 @@
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>126.&nbsp;Deploying a Packaged 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.html" title="Spring Cloud"><link rel="up" href="multi__spring_cloud_function.html" title="Part&nbsp;XVI.&nbsp;Spring Cloud Function"><link rel="prev" href="multi__serverless_platform_adapters.html" title="125.&nbsp;Serverless Platform Adapters"><link rel="next" href="multi__appendix_compendium_of_configuration_properties.html" title="Part&nbsp;XVII.&nbsp;Appendix: Compendium of Configuration Properties"></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">126.&nbsp;Deploying a Packaged Function</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__serverless_platform_adapters.html">Prev</a>&nbsp;</td><th width="60%" align="center">Part&nbsp;XVI.&nbsp;Spring Cloud Function</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="multi__appendix_compendium_of_configuration_properties.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="_deploying_a_packaged_function" href="#_deploying_a_packaged_function"></a>126.&nbsp;Deploying a Packaged Function</h2></div></div></div><p>Spring Cloud Function provides a "deployer" library that allows you to launch a jar file (or exploded archive, or set of jar files) with an isolated class loader and expose the functions defined in it. This is quite a powerful tool that would allow you to, for instance, adapt a function to a range of different input-output adapters without changing the target jar file. Serverless platforms often have this kind of feature built in, so you could see it as a building block for a function invoker in such a platform (indeed the <a class="link" href="https://projectriff.io" target="_top">Riff</a> Java function invoker uses this library).</p><p>The standard entry point of the API is the Spring configuration annotation <code class="literal">@EnableFunctionDeployer</code>. If that is used in a Spring Boot application the deployer kicks in and looks for some configuration to tell it where to find the function jar. At a minimum the user has to provide a <code class="literal">function.location</code> which is a URL or resource location for the archive containing the functions. It can optionally use a <code class="literal">maven:</code> prefix to locate the artifact via a dependency lookup (see <code class="literal">FunctionProperties</code> for complete details). A Spring Boot application is bootstrapped from the jar file, using the <code class="literal">MANIFEST.MF</code> to locate a start class, so that a standard Spring Boot fat jar works well, for example. If the target jar can be launched successfully then the result is a function registered in the main application&#8217;s <code class="literal">FunctionCatalog</code>. The registered function can be applied by code in the main application, even though it was created in an isolated class loader (by default).</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__serverless_platform_adapters.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="multi__spring_cloud_function.html">Up</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="multi__appendix_compendium_of_configuration_properties.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">125.&nbsp;Serverless Platform Adapters&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;Part&nbsp;XVII.&nbsp;Appendix: Compendium of Configuration Properties</td></tr></table></div></body></html>

View File

@@ -0,0 +1,23 @@
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>121.&nbsp;Dynamic Compilation</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.html" title="Spring Cloud"><link rel="up" href="multi__spring_cloud_function.html" title="Part&nbsp;XVI.&nbsp;Spring Cloud Function"><link rel="prev" href="multi__building_and_running_a_function.html" title="120.&nbsp;Building and Running a Function"><link rel="next" href="multi__function_catalog_and_flexible_function_signatures.html" title="122.&nbsp;Function Catalog and Flexible Function Signatures"></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">121.&nbsp;Dynamic Compilation</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__building_and_running_a_function.html">Prev</a>&nbsp;</td><th width="60%" align="center">Part&nbsp;XVI.&nbsp;Spring Cloud Function</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="multi__function_catalog_and_flexible_function_signatures.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="_dynamic_compilation" href="#_dynamic_compilation"></a>121.&nbsp;Dynamic Compilation</h2></div></div></div><p>There is a sample app that uses the function compiler to create a
function from a configuration property. The vanilla "function-sample"
also has that feature. And there are some examples that you can run to
see the compilation happening at run time. To run these examples,
change into the <code class="literal">scripts</code> directory:</p><pre class="screen">cd scripts</pre><p>Also, start a RabbitMQ server locally (e.g. execute <code class="literal">rabbitmq-server</code>).</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_start_the_function_registry_service" href="#_start_the_function_registry_service"></a>121.1&nbsp;Start the Function Registry Service:</h2></div></div></div><pre class="screen">./function-registry.sh</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_register_a_function" href="#_register_a_function"></a>121.2&nbsp;Register a Function:</h2></div></div></div><pre class="screen">./registerFunction.sh -n uppercase -f "f-&gt;f.map(s-&gt;s.toString().toUpperCase())"</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_run_a_rest_microservice_using_that_function" href="#_run_a_rest_microservice_using_that_function"></a>121.3&nbsp;Run a REST Microservice using that Function:</h2></div></div></div><pre class="screen">./web.sh -f uppercase -p 9000
curl -H "Content-Type: text/plain" -H "Accept: text/plain" localhost:9000/uppercase -d foo</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_register_a_supplier" href="#_register_a_supplier"></a>121.4&nbsp;Register a Supplier:</h2></div></div></div><pre class="screen">./registerSupplier.sh -n words -f "()-&gt;Flux.just(\"foo\",\"bar\")"</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_run_a_rest_microservice_using_that_supplier" href="#_run_a_rest_microservice_using_that_supplier"></a>121.5&nbsp;Run a REST Microservice using that Supplier:</h2></div></div></div><pre class="screen">./web.sh -s words -p 9001
curl -H "Accept: application/json" localhost:9001/words</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_register_a_consumer" href="#_register_a_consumer"></a>121.6&nbsp;Register a Consumer:</h2></div></div></div><pre class="screen">./registerConsumer.sh -n print -t String -f "System.out::println"</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_run_a_rest_microservice_using_that_consumer" href="#_run_a_rest_microservice_using_that_consumer"></a>121.7&nbsp;Run a REST Microservice using that Consumer:</h2></div></div></div><pre class="screen">./web.sh -c print -p 9002
curl -X POST -H "Content-Type: text/plain" -d foo localhost:9002/print</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_run_stream_processing_microservices" href="#_run_stream_processing_microservices"></a>121.8&nbsp;Run Stream Processing Microservices:</h2></div></div></div><p>First register a streaming words supplier:</p><pre class="screen">./registerSupplier.sh -n wordstream -f "()-&gt;Flux.interval(Duration.ofMillis(1000)).map(i-&gt;\"message-\"+i)"</pre><p>Then start the source (supplier), processor (function), and sink (consumer) apps
(in reverse order):</p><pre class="screen">./stream.sh -p 9103 -i uppercaseWords -c print
./stream.sh -p 9102 -i words -f uppercase -o uppercaseWords
./stream.sh -p 9101 -s wordstream -o words</pre><p>The output will appear in the console of the sink app (one message per second, converted to uppercase):</p><pre class="screen">MESSAGE-0
MESSAGE-1
MESSAGE-2
MESSAGE-3
MESSAGE-4
MESSAGE-5
MESSAGE-6
MESSAGE-7
MESSAGE-8
MESSAGE-9
...</pre></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>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="multi__spring_cloud_function.html">Up</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="multi__function_catalog_and_flexible_function_signatures.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">120.&nbsp;Building and Running a Function&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;122.&nbsp;Function Catalog and Flexible Function Signatures</td></tr></table></div></body></html>

View File

@@ -0,0 +1,26 @@
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>122.&nbsp;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.html" title="Spring Cloud"><link rel="up" href="multi__spring_cloud_function.html" title="Part&nbsp;XVI.&nbsp;Spring Cloud Function"><link rel="prev" href="multi__dynamic_compilation.html" title="121.&nbsp;Dynamic Compilation"><link rel="next" href="multi__standalone_web_applications.html" title="123.&nbsp;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">122.&nbsp;Function Catalog and Flexible Function Signatures</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__dynamic_compilation.html">Prev</a>&nbsp;</td><th width="60%" align="center">Part&nbsp;XVI.&nbsp;Spring Cloud Function</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="multi__standalone_web_applications.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="_function_catalog_and_flexible_function_signatures" href="#_function_catalog_and_flexible_function_signatures"></a>122.&nbsp;Function Catalog and Flexible Function Signatures</h2></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&lt;String,String&gt;</code>, for
instance, and the <code class="literal">FunctionCatalog</code> will wrap it into a
<code class="literal">Function&lt;Flux&lt;String&gt;,Flux&lt;String&gt;&gt;</code>. Users don&#8217;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
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
transmit headers from any adapter that supports key-value metadata
(e.g. HTTP headers). Here are the details.</p><div class="informaltable"><table style="border-collapse: collapse;border-top: 0.5pt solid ; border-bottom: 0.5pt solid ; "><colgroup><col class="col_1"><col class="col_2"><col class="col_3"></colgroup><thead><tr><th style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top">User Function</th><th style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top">Catalog Registration</th><th style="border-bottom: 0.5pt solid ; " align="left" valign="top">&nbsp;</th></tr></thead><tbody><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p><code class="literal">Function&lt;S,T&gt;</code></p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p><code class="literal">Function&lt;Flux&lt;S&gt;, Flux&lt;T&gt;&gt;</code></p></td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top">&nbsp;</td></tr><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p><code class="literal">Function&lt;Message&lt;S&gt;,Message&lt;T&gt;&gt;</code></p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p><code class="literal">Function&lt;Flux&lt;Message&lt;S&gt;&gt;, Flux&lt;Message&lt;T&gt;&gt;&gt;</code></p></td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top">&nbsp;</td></tr><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p><code class="literal">Function&lt;Flux&lt;S&gt;, Flux&lt;T&gt;&gt;</code></p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p><code class="literal">Function&lt;Flux&lt;S&gt;, Flux&lt;T&gt;&gt;</code> (pass through)</p></td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top">&nbsp;</td></tr><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p><code class="literal">Supplier&lt;T&gt;</code></p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p><code class="literal">Supplier&lt;Flux&lt;T&gt;&gt;</code></p></td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top">&nbsp;</td></tr><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p><code class="literal">Supplier&lt;Flux&lt;T&gt;&gt;</code></p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p><code class="literal">Supplier&lt;Flux&lt;T&gt;&gt;</code></p></td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top">&nbsp;</td></tr><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p><code class="literal">Consumer&lt;T&gt;</code></p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p><code class="literal">Function&lt;Flux&lt;T&gt;, Mono&lt;Void&gt;&gt;</code></p></td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top">&nbsp;</td></tr><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p><code class="literal">Consumer&lt;Message&lt;T&gt;&gt;</code></p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p><code class="literal">Function&lt;Flux&lt;Message&lt;T&gt;&gt;, Mono&lt;Void&gt;&gt;</code></p></td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top">&nbsp;</td></tr><tr><td style="border-right: 0.5pt solid ; " align="left" valign="top"><p><code class="literal">Consumer&lt;Flux&lt;T&gt;&gt;</code></p></td><td style="border-right: 0.5pt solid ; " align="left" valign="top"><p><code class="literal">Consumer&lt;Flux&lt;T&gt;&gt;</code></p></td><td style="" align="left" valign="top">&nbsp;</td></tr></tbody></table></div><p>Consumer is a little bit special because it has a <code class="literal">void</code> return type,
which implies blocking, at least potentially. Most likely you will not
need to write <code class="literal">Consumer&lt;Flux&lt;?&gt;&gt;</code>, but if you do need to do that,
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&lt;Flux&lt;&gt;&gt;</code> with the same name
as a <code class="literal">Function</code>, but it cannot contain a <code class="literal">Consumer&lt;T&gt;</code> and a
<code class="literal">Function&lt;T,S&gt;</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__dynamic_compilation.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="multi__spring_cloud_function.html">Up</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="multi__standalone_web_applications.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">121.&nbsp;Dynamic Compilation&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;123.&nbsp;Standalone Web Applications</td></tr></table></div></body></html>

View File

@@ -0,0 +1,9 @@
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>119.&nbsp;Getting Started</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.html" title="Spring Cloud"><link rel="up" href="multi__spring_cloud_function.html" title="Part&nbsp;XVI.&nbsp;Spring Cloud Function"><link rel="prev" href="multi__introduction_2.html" title="118.&nbsp;Introduction"><link rel="next" href="multi__building_and_running_a_function.html" title="120.&nbsp;Building and Running a Function"></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">119.&nbsp;Getting Started</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__introduction_2.html">Prev</a>&nbsp;</td><th width="60%" align="center">Part&nbsp;XVI.&nbsp;Spring Cloud Function</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="multi__building_and_running_a_function.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="_getting_started" href="#_getting_started"></a>119.&nbsp;Getting Started</h2></div></div></div><p>Build from the command line (and "install" the samples):</p><pre class="screen">$ ./mvnw clean install</pre><p>(If you like to YOLO add <code class="literal">-DskipTests</code>.)</p><p>Run one of the samples, e.g.</p><pre class="screen">$ java -jar spring-cloud-function-samples/function-sample/target/*.jar</pre><p>This runs the app and exposes its functions over HTTP, so you can
convert a string to uppercase, like this:</p><pre class="screen">$ curl -H "Content-Type: text/plain" localhost:8080/uppercase -d Hello
HELLO</pre><p>You can convert multiple strings (a <code class="literal">Flux&lt;String&gt;</code>) by separating them
with new lines</p><pre class="screen">$ curl -H "Content-Type: text/plain" localhost:8080/uppercase -d 'Hello
&gt; World'
HELLOWORLD</pre><p>(You can use <code class="literal"><sup>Q</sup>J</code> in a terminal to insert a new line in a literal
string like that.)</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__introduction_2.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="multi__spring_cloud_function.html">Up</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="multi__building_and_running_a_function.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">118.&nbsp;Introduction&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;120.&nbsp;Building and Running a Function</td></tr></table></div></body></html>

View File

@@ -0,0 +1,27 @@
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>118.&nbsp;Introduction</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.html" title="Spring Cloud"><link rel="up" href="multi__spring_cloud_function.html" title="Part&nbsp;XVI.&nbsp;Spring Cloud Function"><link rel="prev" href="multi__spring_cloud_function.html" title="Part&nbsp;XVI.&nbsp;Spring Cloud Function"><link rel="next" href="multi__getting_started.html" title="119.&nbsp;Getting Started"></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">118.&nbsp;Introduction</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__spring_cloud_function.html">Prev</a>&nbsp;</td><th width="60%" align="center">Part&nbsp;XVI.&nbsp;Spring Cloud Function</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="multi__getting_started.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="_introduction_2" href="#_introduction_2"></a>118.&nbsp;Introduction</h2></div></div></div><p>Spring Cloud Function is a project with the following high-level goals:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><span class="emphasis"><em>Promote the implementation of business logic via functions.</em></span></li><li class="listitem"><span class="emphasis"><em>Decouple the development lifecycle of business logic from any specific runtime target so that the same code can run as a web endpoint, a stream processor, or a task.</em></span></li><li class="listitem"><span class="emphasis"><em>Support a uniform programming model across serverless providers, as well as the ability to run standalone (locally or in a PaaS).</em></span></li><li class="listitem"><span class="emphasis"><em>Enable Spring Boot features (auto-configuration, dependency injection, metrics) on serverless providers.</em></span></li></ul></div><p>It abstracts away all of the transport details and
infrastructure, allowing the developer to keep all the familiar tools
and processes, and focus firmly on business logic.</p><p>Here&#8217;s a complete, executable, testable Spring Boot application
(implementing a simple string manipulation):</p><pre class="programlisting"><em><span class="hl-annotation" style="color: gray">@SpringBootApplication</span></em>
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span> Application {
<em><span class="hl-annotation" style="color: gray">@Bean</span></em>
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> Function&lt;Flux&lt;String&gt;, Flux&lt;String&gt;&gt; uppercase() {
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> flux -&gt; flux.map(value -&gt; value.toUpperCase());
}
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">void</span> main(String[] args) {
SpringApplication.run(Application.<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span>, args);
}
}</pre><p>It&#8217;s just a Spring Boot application, so it can be built, run and
tested, locally and in a CI build, the same way as any other Spring
Boot application. The <code class="literal">Function</code> is from <code class="literal">java.util</code> and <code class="literal">Flux</code> is a
<a class="link" href="http://www.reactive-streams.org/" target="_top">Reactive Streams</a> <code class="literal">Publisher</code> from
<a class="link" href="https://projectreactor.io/" target="_top">Project Reactor</a>. The function can be
accessed over HTTP or messaging.</p><p>Spring Cloud Function has 4 main features:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">Wrappers for <code class="literal">@Beans</code> of type <code class="literal">Function</code>, <code class="literal">Consumer</code> and
<code class="literal">Supplier</code>, exposing them to the outside world as either HTTP
endpoints and/or message stream listeners/publishers with RabbitMQ, Kafka etc.</li><li class="listitem">Compiling strings which are Java function bodies into bytecode, and
then turning them into <code class="literal">@Beans</code> that can be wrapped as above.</li><li class="listitem">Deploying a JAR file containing such an application context with an
isolated classloader, so that you can pack them together in a single
JVM.</li><li class="listitem">Adapters for <a class="link" href="https://github.com/spring-cloud/spring-cloud-function/tree/master/spring-cloud-function-adapters/spring-cloud-function-adapter-aws" target="_top">AWS Lambda</a>, <a class="link" href="https://github.com/spring-cloud/spring-cloud-function/tree/master/spring-cloud-function-adapters/spring-cloud-function-adapter-azure" target="_top">Azure</a>, <a class="link" href="https://github.com/spring-cloud/spring-cloud-function/tree/master/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk" target="_top">Apache OpenWhisk</a> and possibly other "serverless" service providers.</li></ol></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>Spring Cloud is released under the non-restrictive Apache 2.0 license. If you would like to contribute to this section of the documentation or if you find an error, please find the source code and issue trackers in the project at <a class="link" href="https://github.com/spring-cloud/spring-cloud-function/tree/master/docs/src/main/asciidoc" target="_top">github</a>.</p></td></tr></table></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__spring_cloud_function.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="multi__spring_cloud_function.html">Up</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="multi__getting_started.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Part&nbsp;XVI.&nbsp;Spring Cloud Function&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;119.&nbsp;Getting Started</td></tr></table></div></body></html>

View File

@@ -0,0 +1,11 @@
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>125.&nbsp;Serverless Platform Adapters</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.html" title="Spring Cloud"><link rel="up" href="multi__spring_cloud_function.html" title="Part&nbsp;XVI.&nbsp;Spring Cloud Function"><link rel="prev" href="multi__standalone_streaming_applications.html" title="124.&nbsp;Standalone Streaming Applications"><link rel="next" href="multi__deploying_a_packaged_function.html" title="126.&nbsp;Deploying a Packaged Function"></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">125.&nbsp;Serverless Platform Adapters</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__standalone_streaming_applications.html">Prev</a>&nbsp;</td><th width="60%" align="center">Part&nbsp;XVI.&nbsp;Spring Cloud Function</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="multi__deploying_a_packaged_function.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="_serverless_platform_adapters" href="#_serverless_platform_adapters"></a>125.&nbsp;Serverless Platform Adapters</h2></div></div></div><p>As well as being able to run as a standalone process, a Spring Cloud
Function application can be adapted to run one of the existing
servlerless platforms. In the project there are adapters for
<a class="link" href="https://github.com/spring-cloud/spring-cloud-function/tree/master/spring-cloud-function-adapters/spring-cloud-function-adapter-aws" target="_top">AWS
Lambda</a>,
<a class="link" href="https://github.com/spring-cloud/spring-cloud-function/tree/master/spring-cloud-function-adapters/spring-cloud-function-adapter-azure" target="_top">Azure</a>,
and
<a class="link" href="https://github.com/spring-cloud/spring-cloud-function/tree/master/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk" target="_top">Apache
OpenWhisk</a>. The Oracle Fn platform has its own Spring Cloud Function adapter.</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__standalone_streaming_applications.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="multi__spring_cloud_function.html">Up</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="multi__deploying_a_packaged_function.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">124.&nbsp;Standalone Streaming Applications&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;126.&nbsp;Deploying a Packaged Function</td></tr></table></div></body></html>

View File

@@ -0,0 +1,3 @@
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Part&nbsp;XVI.&nbsp;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.html" title="Spring Cloud"><link rel="up" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="prev" href="multi__building_a_simple_gateway_using_spring_mvc_or_webflux.html" title="117.&nbsp;Building a Simple Gateway Using Spring MVC or Webflux"><link rel="next" href="multi__introduction_2.html" title="118.&nbsp;Introduction"></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">Part&nbsp;XVI.&nbsp;Spring Cloud Function</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__building_a_simple_gateway_using_spring_mvc_or_webflux.html">Prev</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="multi__introduction_2.html">Next</a></td></tr></table><hr></div><div class="part"><div class="titlepage"><div><div><h1 class="title"><a name="_spring_cloud_function" href="#_spring_cloud_function"></a>Part&nbsp;XVI.&nbsp;Spring Cloud Function</h1></div></div></div><div class="partintro"><div></div><p>Mark Fisher, Dave Syer</p><p></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_a_simple_gateway_using_spring_mvc_or_webflux.html">Prev</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="multi__introduction_2.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">117.&nbsp;Building a Simple Gateway Using Spring MVC or Webflux&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;118.&nbsp;Introduction</td></tr></table></div></body></html>

View File

@@ -0,0 +1,3 @@
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>124.&nbsp;Standalone Streaming Applications</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.html" title="Spring Cloud"><link rel="up" href="multi__spring_cloud_function.html" title="Part&nbsp;XVI.&nbsp;Spring Cloud Function"><link rel="prev" href="multi__standalone_web_applications.html" title="123.&nbsp;Standalone Web Applications"><link rel="next" href="multi__serverless_platform_adapters.html" title="125.&nbsp;Serverless Platform Adapters"></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">124.&nbsp;Standalone Streaming Applications</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__standalone_web_applications.html">Prev</a>&nbsp;</td><th width="60%" align="center">Part&nbsp;XVI.&nbsp;Spring Cloud Function</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="multi__serverless_platform_adapters.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="_standalone_streaming_applications" href="#_standalone_streaming_applications"></a>124.&nbsp;Standalone Streaming Applications</h2></div></div></div><p>To send or receive messages from a broker (such as RabbitMQ or Kafka) you can use the <code class="literal">spring-cloud-function-stream</code> adapter. Add the adapter to your classpath along with the appropriate binder from Spring Cloud Stream. The adapter will bind to the message broker as a <code class="literal">Processor</code> (input and output streams) unless the user explicitly disables one or the other using <code class="literal">spring.cloud.function.stream.{source,sink}.enabled=false</code>.</p><p>An incoming message is routed to a function (or consumer). If there is only one, then the choice is obvious. If there are multiple functions that can accept an incoming message, the message is inspected to see if there is a <code class="literal">stream_routekey</code> header containing the name of a function. Routing headers or function names can be composed using a comma- or pipe-separated name. The header is also added to outgoing messages from a supplier. Messages with no route key can be routed exclusively to a function or consumer by specifying <code class="literal">spring.cloud.function.stream.{processor,sink}.name</code>. If a single function cannot be identified to process an incoming message there will be an error, unless you set <code class="literal">spring.cloud.function.stream.shared=true</code>, in which case such messages will be sent to all compatible functions. A single supplier can be chosen for output messages from a supplier (if more than one is available) using the <code class="literal">spring.cloud.function.stream.source.name</code>.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>some binders will fail on startup if the message broker is not available and the function catalog contains suppliers that immediately produce messages when accessed. You can switch off the automatic publishing from suppliers on startup using the <code class="literal">spring.cloud.function.strean.supplier.enabled=false</code> flag.</p></td></tr></table></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__standalone_web_applications.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="multi__spring_cloud_function.html">Up</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="multi__serverless_platform_adapters.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">123.&nbsp;Standalone Web Applications&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;125.&nbsp;Serverless Platform Adapters</td></tr></table></div></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -25257,7 +25257,371 @@ public ResponseEntity&lt;?&gt; proxyPath(ProxyExchange&lt;byte[]&gt; proxy) thro
<simpara>Headers can be added to the downstream response using the <literal>header()</literal> methods on <literal>ProxyExchange</literal>.</simpara>
<simpara>You can also manipulate response headers (and anything else you like in the response) by adding a mapper to the <literal>get()</literal> etc. method. The mapper is a <literal>Function</literal> that takes the incoming <literal>ResponseEntity</literal> and converts it to an outgoing one.</simpara>
<simpara>First class support is provided for "sensitive" headers ("cookie" and "authorization" by default) which are not passed downstream, and for "proxy" headers (<literal>x-forwarded-*</literal>).</simpara>
<simpara>Unresolved directive in spring-cloud.adoc - include::../../../../gateway/docs/src/main/asciidoc/spring-cloud-function.adoc[]</simpara>
</chapter>
</part>
<part xml:id="_spring_cloud_function">
<title>Spring Cloud Function</title>
<partintro>
<simpara>Mark Fisher, Dave Syer</simpara>
<simpara><?asciidoc-hr?></simpara>
</partintro>
<chapter xml:id="_introduction_2">
<title>Introduction</title>
<simpara>Spring Cloud Function is a project with the following high-level goals:</simpara>
<itemizedlist>
<listitem>
<simpara><emphasis>Promote the implementation of business logic via functions.</emphasis></simpara>
</listitem>
<listitem>
<simpara><emphasis>Decouple the development lifecycle of business logic from any specific runtime target so that the same code can run as a web endpoint, a stream processor, or a task.</emphasis></simpara>
</listitem>
<listitem>
<simpara><emphasis>Support a uniform programming model across serverless providers, as well as the ability to run standalone (locally or in a PaaS).</emphasis></simpara>
</listitem>
<listitem>
<simpara><emphasis>Enable Spring Boot features (auto-configuration, dependency injection, metrics) on serverless providers.</emphasis></simpara>
</listitem>
</itemizedlist>
<simpara>It abstracts away all of the transport details and
infrastructure, allowing the developer to keep all the familiar tools
and processes, and focus firmly on business logic.</simpara>
<simpara>Here&#8217;s a complete, executable, testable Spring Boot application
(implementing a simple string manipulation):</simpara>
<programlisting language="java" linenumbering="unnumbered">@SpringBootApplication
public class Application {
@Bean
public Function&lt;Flux&lt;String&gt;, Flux&lt;String&gt;&gt; uppercase() {
return flux -&gt; flux.map(value -&gt; value.toUpperCase());
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}</programlisting>
<simpara>It&#8217;s just a Spring Boot application, so it can be built, run and
tested, locally and in a CI build, the same way as any other Spring
Boot application. The <literal>Function</literal> is from <literal>java.util</literal> and <literal>Flux</literal> is a
<link xl:href="http://www.reactive-streams.org/">Reactive Streams</link> <literal>Publisher</literal> from
<link xl:href="https://projectreactor.io/">Project Reactor</link>. The function can be
accessed over HTTP or messaging.</simpara>
<simpara>Spring Cloud Function has 4 main features:</simpara>
<orderedlist numeration="arabic">
<listitem>
<simpara>Wrappers for <literal>@Beans</literal> of type <literal>Function</literal>, <literal>Consumer</literal> and
<literal>Supplier</literal>, exposing them to the outside world as either HTTP
endpoints and/or message stream listeners/publishers with RabbitMQ, Kafka etc.</simpara>
</listitem>
<listitem>
<simpara>Compiling strings which are Java function bodies into bytecode, and
then turning them into <literal>@Beans</literal> that can be wrapped as above.</simpara>
</listitem>
<listitem>
<simpara>Deploying a JAR file containing such an application context with an
isolated classloader, so that you can pack them together in a single
JVM.</simpara>
</listitem>
<listitem>
<simpara>Adapters for <link xl:href="https://github.com/spring-cloud/spring-cloud-function/tree/master/spring-cloud-function-adapters/spring-cloud-function-adapter-aws">AWS Lambda</link>, <link xl:href="https://github.com/spring-cloud/spring-cloud-function/tree/master/spring-cloud-function-adapters/spring-cloud-function-adapter-azure">Azure</link>, <link xl:href="https://github.com/spring-cloud/spring-cloud-function/tree/master/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk">Apache OpenWhisk</link> and possibly other "serverless" service providers.</simpara>
</listitem>
</orderedlist>
<note>
<simpara>Spring Cloud is released under the non-restrictive Apache 2.0 license. If you would like to contribute to this section of the documentation or if you find an error, please find the source code and issue trackers in the project at <link xl:href="https://github.com/spring-cloud/spring-cloud-function/tree/master/docs/src/main/asciidoc">github</link>.</simpara>
</note>
</chapter>
<chapter xml:id="_getting_started">
<title>Getting Started</title>
<simpara>Build from the command line (and "install" the samples):</simpara>
<screen>$ ./mvnw clean install</screen>
<simpara>(If you like to YOLO add <literal>-DskipTests</literal>.)</simpara>
<simpara>Run one of the samples, e.g.</simpara>
<screen>$ java -jar spring-cloud-function-samples/function-sample/target/*.jar</screen>
<simpara>This runs the app and exposes its functions over HTTP, so you can
convert a string to uppercase, like this:</simpara>
<screen>$ curl -H "Content-Type: text/plain" localhost:8080/uppercase -d Hello
HELLO</screen>
<simpara>You can convert multiple strings (a <literal>Flux&lt;String&gt;</literal>) by separating them
with new lines</simpara>
<screen>$ curl -H "Content-Type: text/plain" localhost:8080/uppercase -d 'Hello
&gt; World'
HELLOWORLD</screen>
<simpara>(You can use <literal><superscript>Q</superscript>J</literal> in a terminal to insert a new line in a literal
string like that.)</simpara>
</chapter>
<chapter xml:id="_building_and_running_a_function">
<title>Building and Running a Function</title>
<simpara>The sample <literal>@SpringBootApplication</literal> above has a function that can be
decorated at runtime by Spring Cloud Function to be an HTTP endpoint,
or a Stream processor, for instance with RabbitMQ, Apache Kafka or
JMS.</simpara>
<simpara>The <literal>@Beans</literal> can be <literal>Function</literal>, <literal>Consumer</literal> or <literal>Supplier</literal> (all from
<literal>java.util</literal>), and their parametric types can be String or POJO. A
<literal>Function</literal> is exposed as a Spring Cloud Stream <literal>Processor</literal> if
<literal>spring-cloud-function-stream</literal> is on the classpath.
A <literal>Consumer</literal> is also exposed as a Stream
<literal>Sink</literal> and a <literal>Supplier</literal> translates to a Stream <literal>Source</literal>.
HTTP endpoints are exposed if the Stream binder is <literal>spring-cloud-stream-binder-servlet</literal>.</simpara>
<simpara>Functions can be of <literal>Flux&lt;String&gt;</literal> or <literal>Flux&lt;Pojo&gt;</literal> and Spring Cloud
Function takes care of converting the data to and from the desired
types, as long as it comes in as plain text or (in the case of the
POJO) JSON. TBD: support for <literal>Flux&lt;Message&lt;Pojo&gt;&gt;</literal> and maybe plain
<literal>Pojo</literal> types (Fluxes implied and implemented by the framework).</simpara>
<simpara>Functions can be grouped together in a single application, or deployed
one-per-jar. It&#8217;s up to the developer to choose. An app with multiple
functions can be deployed multiple times in different "personalities",
exposing different functions over different physical transports.</simpara>
</chapter>
<chapter xml:id="_dynamic_compilation">
<title>Dynamic Compilation</title>
<simpara>There is a sample app that uses the function compiler to create a
function from a configuration property. The vanilla "function-sample"
also has that feature. And there are some examples that you can run to
see the compilation happening at run time. To run these examples,
change into the <literal>scripts</literal> directory:</simpara>
<screen>cd scripts</screen>
<simpara>Also, start a RabbitMQ server locally (e.g. execute <literal>rabbitmq-server</literal>).</simpara>
<section xml:id="_start_the_function_registry_service">
<title>Start the Function Registry Service:</title>
<screen>./function-registry.sh</screen>
</section>
<section xml:id="_register_a_function">
<title>Register a Function:</title>
<screen>./registerFunction.sh -n uppercase -f "f-&gt;f.map(s-&gt;s.toString().toUpperCase())"</screen>
</section>
<section xml:id="_run_a_rest_microservice_using_that_function">
<title>Run a REST Microservice using that Function:</title>
<screen>./web.sh -f uppercase -p 9000
curl -H "Content-Type: text/plain" -H "Accept: text/plain" localhost:9000/uppercase -d foo</screen>
</section>
<section xml:id="_register_a_supplier">
<title>Register a Supplier:</title>
<screen>./registerSupplier.sh -n words -f "()-&gt;Flux.just(\"foo\",\"bar\")"</screen>
</section>
<section xml:id="_run_a_rest_microservice_using_that_supplier">
<title>Run a REST Microservice using that Supplier:</title>
<screen>./web.sh -s words -p 9001
curl -H "Accept: application/json" localhost:9001/words</screen>
</section>
<section xml:id="_register_a_consumer">
<title>Register a Consumer:</title>
<screen>./registerConsumer.sh -n print -t String -f "System.out::println"</screen>
</section>
<section xml:id="_run_a_rest_microservice_using_that_consumer">
<title>Run a REST Microservice using that Consumer:</title>
<screen>./web.sh -c print -p 9002
curl -X POST -H "Content-Type: text/plain" -d foo localhost:9002/print</screen>
</section>
<section xml:id="_run_stream_processing_microservices">
<title>Run Stream Processing Microservices:</title>
<simpara>First register a streaming words supplier:</simpara>
<screen>./registerSupplier.sh -n wordstream -f "()-&gt;Flux.interval(Duration.ofMillis(1000)).map(i-&gt;\"message-\"+i)"</screen>
<simpara>Then start the source (supplier), processor (function), and sink (consumer) apps
(in reverse order):</simpara>
<screen>./stream.sh -p 9103 -i uppercaseWords -c print
./stream.sh -p 9102 -i words -f uppercase -o uppercaseWords
./stream.sh -p 9101 -s wordstream -o words</screen>
<simpara>The output will appear in the console of the sink app (one message per second, converted to uppercase):</simpara>
<screen>MESSAGE-0
MESSAGE-1
MESSAGE-2
MESSAGE-3
MESSAGE-4
MESSAGE-5
MESSAGE-6
MESSAGE-7
MESSAGE-8
MESSAGE-9
...</screen>
</section>
</chapter>
<chapter xml:id="_function_catalog_and_flexible_function_signatures">
<title>Function Catalog and Flexible Function Signatures</title>
<simpara>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 <literal>Function&lt;String,String&gt;</literal>, for
instance, and the <literal>FunctionCatalog</literal> will wrap it into a
<literal>Function&lt;Flux&lt;String&gt;,Flux&lt;String&gt;&gt;</literal>. Users don&#8217;t normally have to
care about the <literal>FunctionCatalog</literal> at all, but it is useful to know what
kind of functions are supported in user code.</simpara>
<simpara>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 <literal>Flux</literal> of the same type. If the user writes
a function using <literal>Message</literal> (from spring-messaging) it will receive and
transmit headers from any adapter that supports key-value metadata
(e.g. HTTP headers). Here are the details.</simpara>
<informaltable frame="topbot" rowsep="1" colsep="1">
<tgroup cols="3">
<colspec colname="col_1" colwidth="33.3333*"/>
<colspec colname="col_2" colwidth="33.3333*"/>
<colspec colname="col_3" colwidth="33.3334*"/>
<thead>
<row>
<entry align="left" valign="top">User Function</entry>
<entry align="left" valign="top">Catalog Registration</entry>
<entry align="left" valign="top"></entry>
</row>
</thead>
<tbody>
<row>
<entry align="left" valign="top"><simpara><literal>Function&lt;S,T&gt;</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>Function&lt;Flux&lt;S&gt;, Flux&lt;T&gt;&gt;</literal></simpara></entry>
<entry align="left" valign="top"></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><literal>Function&lt;Message&lt;S&gt;,Message&lt;T&gt;&gt;</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>Function&lt;Flux&lt;Message&lt;S&gt;&gt;, Flux&lt;Message&lt;T&gt;&gt;&gt;</literal></simpara></entry>
<entry align="left" valign="top"></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><literal>Function&lt;Flux&lt;S&gt;, Flux&lt;T&gt;&gt;</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>Function&lt;Flux&lt;S&gt;, Flux&lt;T&gt;&gt;</literal> (pass through)</simpara></entry>
<entry align="left" valign="top"></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><literal>Supplier&lt;T&gt;</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>Supplier&lt;Flux&lt;T&gt;&gt;</literal></simpara></entry>
<entry align="left" valign="top"></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><literal>Supplier&lt;Flux&lt;T&gt;&gt;</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>Supplier&lt;Flux&lt;T&gt;&gt;</literal></simpara></entry>
<entry align="left" valign="top"></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><literal>Consumer&lt;T&gt;</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>Function&lt;Flux&lt;T&gt;, Mono&lt;Void&gt;&gt;</literal></simpara></entry>
<entry align="left" valign="top"></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><literal>Consumer&lt;Message&lt;T&gt;&gt;</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>Function&lt;Flux&lt;Message&lt;T&gt;&gt;, Mono&lt;Void&gt;&gt;</literal></simpara></entry>
<entry align="left" valign="top"></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><literal>Consumer&lt;Flux&lt;T&gt;&gt;</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>Consumer&lt;Flux&lt;T&gt;&gt;</literal></simpara></entry>
<entry align="left" valign="top"></entry>
</row>
</tbody>
</tgroup>
</informaltable>
<simpara>Consumer is a little bit special because it has a <literal>void</literal> return type,
which implies blocking, at least potentially. Most likely you will not
need to write <literal>Consumer&lt;Flux&lt;?&gt;&gt;</literal>, but if you do need to do that,
remember to subscribe to the input flux. If you declare a <literal>Consumer</literal>
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.</simpara>
<simpara>A function catalog can contain a <literal>Supplier</literal> and a <literal>Function</literal> (or
<literal>Consumer</literal>) with the same name (like a GET and a POST to the same
resource). It can even contain a <literal>Consumer&lt;Flux&lt;&gt;&gt;</literal> with the same name
as a <literal>Function</literal>, but it cannot contain a <literal>Consumer&lt;T&gt;</literal> and a
<literal>Function&lt;T,S&gt;</literal> with the same name when <literal>T</literal> is not a <literal>Publisher</literal>
because the consumer would be converted to a <literal>Function</literal> and only one
of them can be registered.</simpara>
</chapter>
<chapter xml:id="_standalone_web_applications">
<title>Standalone Web Applications</title>
<simpara>The <literal>spring-cloud-function-web</literal> module has autoconfiguration that
activates when it is included in a Spring Boot web application (with
MVC support). There is also a <literal>spring-cloud-starter-function-web</literal> to
collect all the optional dependnecies in case you just want a simple
getting started experience.</simpara>
<simpara>With the web configurations activated your app will have an MVC
endpoint (on "/" by default, but configurable with
<literal>spring.cloud.function.web.path</literal>) that can be used to access the
functions in the application context. The supported content types are
plain text and JSON.</simpara>
<informaltable frame="topbot" rowsep="1" colsep="1">
<tgroup cols="5">
<colspec colname="col_1" colwidth="20*"/>
<colspec colname="col_2" colwidth="20*"/>
<colspec colname="col_3" colwidth="20*"/>
<colspec colname="col_4" colwidth="20*"/>
<colspec colname="col_5" colwidth="20*"/>
<thead>
<row>
<entry align="left" valign="top">Method</entry>
<entry align="left" valign="top">Path</entry>
<entry align="left" valign="top">Request</entry>
<entry align="left" valign="top">Response</entry>
<entry align="left" valign="top">Status</entry>
</row>
</thead>
<tbody>
<row>
<entry align="left" valign="top"><simpara>GET</simpara></entry>
<entry align="left" valign="top"><simpara>/{supplier}</simpara></entry>
<entry align="left" valign="top"><simpara>-</simpara></entry>
<entry align="left" valign="top"><simpara>Items from the named supplier</simpara></entry>
<entry align="left" valign="top"><simpara>200 OK</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara>POST</simpara></entry>
<entry align="left" valign="top"><simpara>/{consumer}</simpara></entry>
<entry align="left" valign="top"><simpara>JSON object or text</simpara></entry>
<entry align="left" valign="top"><simpara>Mirrors input and pushes request body into consumer</simpara></entry>
<entry align="left" valign="top"><simpara>202 Accepted</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara>POST</simpara></entry>
<entry align="left" valign="top"><simpara>/{consumer}</simpara></entry>
<entry align="left" valign="top"><simpara>JSON array or text with new lines</simpara></entry>
<entry align="left" valign="top"><simpara>Mirrors input and pushes body into consumer one by one</simpara></entry>
<entry align="left" valign="top"><simpara>202 Accepted</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara>POST</simpara></entry>
<entry align="left" valign="top"><simpara>/{function}</simpara></entry>
<entry align="left" valign="top"><simpara>JSON object or text</simpara></entry>
<entry align="left" valign="top"><simpara>The result of applying the named function</simpara></entry>
<entry align="left" valign="top"><simpara>200 OK</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara>POST</simpara></entry>
<entry align="left" valign="top"><simpara>/{function}</simpara></entry>
<entry align="left" valign="top"><simpara>JSON array or text with new lines</simpara></entry>
<entry align="left" valign="top"><simpara>The result of applying the named function</simpara></entry>
<entry align="left" valign="top"><simpara>200 OK</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara>GET</simpara></entry>
<entry align="left" valign="top"><simpara>/{function}/{item}</simpara></entry>
<entry align="left" valign="top"><simpara>-</simpara></entry>
<entry align="left" valign="top"><simpara>Convert the item into an object and return the result of applying the function</simpara></entry>
<entry align="left" valign="top"><simpara>200 OK</simpara></entry>
</row>
</tbody>
</tgroup>
</informaltable>
<simpara>As the table above shows the behaviour of the endpoint depends on the method and also the type of incoming request data. When the incoming data is single valued, and the target function is declared as obviously single valued (i.e. not returning a collection or <literal>Flux</literal>), then the response will also contain a single value. For multi-valued responses the client can ask for a server-sent event stream by sending `Accept: text/event-stream". If there is only one function (consumer etc.) then the name in the path is optional. Composite functions can be addressed using pipes or commas to separate function names (pipes are legal in URL paths, but a bit awkward to type on the command line).</simpara>
<simpara>Functions and consumers that are declared with input and output in <literal>Message&lt;?&gt;</literal> will see the request headers on the input messages, and the output message headers will be converted to HTTP headers.</simpara>
<simpara>When POSTing text the response format might be different with Spring Boot 2.0 and older versions, depending on the content negotiation (provide content type and accpt headers for the best results).</simpara>
</chapter>
<chapter xml:id="_standalone_streaming_applications">
<title>Standalone Streaming Applications</title>
<simpara>To send or receive messages from a broker (such as RabbitMQ or Kafka) you can use the <literal>spring-cloud-function-stream</literal> adapter. Add the adapter to your classpath along with the appropriate binder from Spring Cloud Stream. The adapter will bind to the message broker as a <literal>Processor</literal> (input and output streams) unless the user explicitly disables one or the other using <literal>spring.cloud.function.stream.{source,sink}.enabled=false</literal>.</simpara>
<simpara>An incoming message is routed to a function (or consumer). If there is only one, then the choice is obvious. If there are multiple functions that can accept an incoming message, the message is inspected to see if there is a <literal>stream_routekey</literal> header containing the name of a function. Routing headers or function names can be composed using a comma- or pipe-separated name. The header is also added to outgoing messages from a supplier. Messages with no route key can be routed exclusively to a function or consumer by specifying <literal>spring.cloud.function.stream.{processor,sink}.name</literal>. If a single function cannot be identified to process an incoming message there will be an error, unless you set <literal>spring.cloud.function.stream.shared=true</literal>, in which case such messages will be sent to all compatible functions. A single supplier can be chosen for output messages from a supplier (if more than one is available) using the <literal>spring.cloud.function.stream.source.name</literal>.</simpara>
<note>
<simpara>some binders will fail on startup if the message broker is not available and the function catalog contains suppliers that immediately produce messages when accessed. You can switch off the automatic publishing from suppliers on startup using the <literal>spring.cloud.function.strean.supplier.enabled=false</literal> flag.</simpara>
</note>
</chapter>
<chapter xml:id="_serverless_platform_adapters">
<title>Serverless Platform Adapters</title>
<simpara>As well as being able to run as a standalone process, a Spring Cloud
Function application can be adapted to run one of the existing
servlerless platforms. In the project there are adapters for
<link xl:href="https://github.com/spring-cloud/spring-cloud-function/tree/master/spring-cloud-function-adapters/spring-cloud-function-adapter-aws">AWS
Lambda</link>,
<link xl:href="https://github.com/spring-cloud/spring-cloud-function/tree/master/spring-cloud-function-adapters/spring-cloud-function-adapter-azure">Azure</link>,
and
<link xl:href="https://github.com/spring-cloud/spring-cloud-function/tree/master/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk">Apache
OpenWhisk</link>. The Oracle Fn platform has its own Spring Cloud Function adapter.</simpara>
</chapter>
<chapter xml:id="_deploying_a_packaged_function">
<title>Deploying a Packaged Function</title>
<simpara>Spring Cloud Function provides a "deployer" library that allows you to launch a jar file (or exploded archive, or set of jar files) with an isolated class loader and expose the functions defined in it. This is quite a powerful tool that would allow you to, for instance, adapt a function to a range of different input-output adapters without changing the target jar file. Serverless platforms often have this kind of feature built in, so you could see it as a building block for a function invoker in such a platform (indeed the <link xl:href="https://projectriff.io">Riff</link> Java function invoker uses this library).</simpara>
<simpara>The standard entry point of the API is the Spring configuration annotation <literal>@EnableFunctionDeployer</literal>. If that is used in a Spring Boot application the deployer kicks in and looks for some configuration to tell it where to find the function jar. At a minimum the user has to provide a <literal>function.location</literal> which is a URL or resource location for the archive containing the functions. It can optionally use a <literal>maven:</literal> prefix to locate the artifact via a dependency lookup (see <literal>FunctionProperties</literal> for complete details). A Spring Boot application is bootstrapped from the jar file, using the <literal>MANIFEST.MF</literal> to locate a start class, so that a standard Spring Boot fat jar works well, for example. If the target jar can be launched successfully then the result is a function registered in the main application&#8217;s <literal>FunctionCatalog</literal>. The registered function can be applied by code in the main application, even though it was created in an isolated class loader (by default).</simpara>
</chapter>
</part>
<part xml:id="_appendix_compendium_of_configuration_properties">