Sync docs from master to gh-pages
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<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-singlepage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><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="#d0e9"></a></span></dt><dt><span class="chapter"><a href="#_introduction">1. Introduction</a></span></dt><dt><span class="chapter"><a href="#_getting_started">2. Getting Started</a></span></dt><dt><span class="chapter"><a href="#_building_and_running_a_function">3. Building and Running a Function</a></span></dt><dt><span class="chapter"><a href="#_function_catalog_and_flexible_function_signatures">4. Function Catalog and Flexible Function Signatures</a></span></dt><dt><span class="chapter"><a href="#_standalone_web_applications">5. Standalone Web Applications</a></span></dt><dt><span class="chapter"><a href="#_standalone_streaming_applications">6. Standalone Streaming Applications</a></span></dt><dt><span class="chapter"><a href="#_deploying_a_packaged_function">7. Deploying a Packaged Function</a></span></dt><dt><span class="chapter"><a href="#_dynamic_compilation">8. Dynamic Compilation</a></span></dt><dt><span class="chapter"><a href="#_serverless_platform_adapters">9. Serverless Platform Adapters</a></span></dt><dd><dl><dt><span class="section"><a href="#_aws_lambda">9.1. AWS Lambda</a></span></dt><dd><dl><dt><span class="section"><a href="#_introduction_2">9.1.1. Introduction</a></span></dt><dt><span class="section"><a href="#_notes_on_jar_layout">9.1.2. Notes on JAR Layout</a></span></dt><dt><span class="section"><a href="#_upload">9.1.3. Upload</a></span></dt><dt><span class="section"><a href="#_platfom_specific_features">9.1.4. Platfom Specific Features</a></span></dt><dd><dl><dt><span class="section"><a href="#_http_and_api_gateway">HTTP and API Gateway</a></span></dt></dl></dd></dl></dd><dt><span class="section"><a href="#_azure_functions">9.2. Azure Functions</a></span></dt><dd><dl><dt><span class="section"><a href="#_notes_on_jar_layout_2">9.2.1. Notes on JAR Layout</a></span></dt><dt><span class="section"><a href="#_json_configuration">9.2.2. JSON Configuration</a></span></dt><dt><span class="section"><a href="#_build">9.2.3. Build</a></span></dt><dt><span class="section"><a href="#_running_the_sample">9.2.4. Running the sample</a></span></dt></dl></dd><dt><span class="section"><a href="#_apache_openwhisk">9.3. Apache Openwhisk</a></span></dt><dd><dl><dt><span class="section"><a href="#_quick_start">9.3.1. Quick Start</a></span></dt></dl></dd></dl></dd></dl></div><div class="preface"><div class="titlepage"><div><div><h1 class="title"><a name="d0e9" href="#d0e9"></a></h1></div></div></div><p>Mark Fisher, Dave Syer, Oleg Zhurakousky</p><p></p></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="_introduction" href="#_introduction"></a>1. Introduction</h1></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">Promote the implementation of business logic via functions.</li><li class="listitem">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.</li><li class="listitem">Support a uniform programming model across serverless providers, as well as the ability to run standalone (locally or in a PaaS).</li><li class="listitem">Enable Spring Boot features (auto-configuration, dependency injection, metrics) on serverless providers.</li></ul></div><p>It abstracts away all of the transport details and
|
||||
<title>Spring Cloud Function</title><link rel="stylesheet" type="text/css" href="css/manual-singlepage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><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="#d0e9"></a></span></dt><dt><span class="chapter"><a href="#_introduction">1. Introduction</a></span></dt><dt><span class="chapter"><a href="#_getting_started">2. Getting Started</a></span></dt><dt><span class="chapter"><a href="#_building_and_running_a_function">3. Building and Running a Function</a></span></dt><dt><span class="chapter"><a href="#_function_catalog_and_flexible_function_signatures">4. Function Catalog and Flexible Function Signatures</a></span></dt><dd><dl><dt><span class="section"><a href="#_java_8_function_support">4.1. Java 8 function support</a></span></dt><dt><span class="section"><a href="#_kotlin_lambda_support">4.2. Kotlin Lambda support</a></span></dt></dl></dd><dt><span class="chapter"><a href="#_standalone_web_applications">5. Standalone Web Applications</a></span></dt><dt><span class="chapter"><a href="#_standalone_streaming_applications">6. Standalone Streaming Applications</a></span></dt><dt><span class="chapter"><a href="#_deploying_a_packaged_function">7. Deploying a Packaged Function</a></span></dt><dt><span class="chapter"><a href="#_dynamic_compilation">8. Dynamic Compilation</a></span></dt><dt><span class="chapter"><a href="#_serverless_platform_adapters">9. Serverless Platform Adapters</a></span></dt><dd><dl><dt><span class="section"><a href="#_aws_lambda">9.1. AWS Lambda</a></span></dt><dd><dl><dt><span class="section"><a href="#_introduction_2">9.1.1. Introduction</a></span></dt><dt><span class="section"><a href="#_notes_on_jar_layout">9.1.2. Notes on JAR Layout</a></span></dt><dt><span class="section"><a href="#_upload">9.1.3. Upload</a></span></dt><dt><span class="section"><a href="#_platfom_specific_features">9.1.4. Platfom Specific Features</a></span></dt><dd><dl><dt><span class="section"><a href="#_http_and_api_gateway">HTTP and API Gateway</a></span></dt></dl></dd></dl></dd><dt><span class="section"><a href="#_azure_functions">9.2. Azure Functions</a></span></dt><dd><dl><dt><span class="section"><a href="#_notes_on_jar_layout_2">9.2.1. Notes on JAR Layout</a></span></dt><dt><span class="section"><a href="#_json_configuration">9.2.2. JSON Configuration</a></span></dt><dt><span class="section"><a href="#_build">9.2.3. Build</a></span></dt><dt><span class="section"><a href="#_running_the_sample">9.2.4. Running the sample</a></span></dt></dl></dd><dt><span class="section"><a href="#_apache_openwhisk">9.3. Apache Openwhisk</a></span></dt><dd><dl><dt><span class="section"><a href="#_quick_start">9.3.1. Quick Start</a></span></dt></dl></dd></dl></dd></dl></div><div class="preface"><div class="titlepage"><div><div><h1 class="title"><a name="d0e9" href="#d0e9"></a></h1></div></div></div><p>Mark Fisher, Dave Syer, Oleg Zhurakousky</p><p></p></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="_introduction" href="#_introduction"></a>1. Introduction</h1></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">Promote the implementation of business logic via functions.</li><li class="listitem">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.</li><li class="listitem">Support a uniform programming model across serverless providers, as well as the ability to run standalone (locally or in a PaaS).</li><li class="listitem">Enable Spring Boot features (auto-configuration, dependency injection, metrics) on serverless providers.</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’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>
|
||||
@@ -46,13 +46,14 @@ POJO) JSON. TBD: support for <code class="literal">Flux<Message<Pojo>&g
|
||||
<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’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="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
|
||||
exposing different functions over different physical transports.</p></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
|
||||
@@ -63,13 +64,24 @@ 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="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="_standalone_web_applications" href="#_standalone_web_applications"></a>5. Standalone Web Applications</h1></div></div></div><p>The <code class="literal">spring-cloud-function-web</code> module has autoconfiguration that
|
||||
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="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="_standalone_web_applications" href="#_standalone_web_applications"></a>5. Standalone Web Applications</h1></div></div></div><p>The <code class="literal">spring-cloud-function-web</code> module has autoconfiguration that
|
||||
activates when it is included in a Spring Boot web application (with
|
||||
MVC support). There is also a <code class="literal">spring-cloud-starter-function-web</code> to
|
||||
collect all the optional dependnecies in case you just want a simple
|
||||
|
||||
Reference in New Issue
Block a user