Sync docs from master to gh-pages

This commit is contained in:
buildmaster
2020-04-06 08:55:46 +00:00
parent 574505e634
commit e9e60324d1
27 changed files with 819 additions and 99 deletions

View File

@@ -86,7 +86,26 @@ function createSwitchItem(block, blockSwitch) {
return {'item': item, 'content': content};
}
function globalSwitch() {
$('.switch--item').each(function() {
$(this).off('click');
$(this).on('click', function() {
selectedText = $(this).text()
selectedIndex = $(this).index()
$(".switch--item").filter(function() { return ($(this).text() === selectedText) }).each(function() {
$(this).addClass('selected');
$(this).siblings().removeClass('selected');
selectedContent = $(this).parent().siblings(".content").eq(selectedIndex)
selectedContent.removeClass('hidden');
selectedContent.siblings().addClass('hidden');
});
});
});
}
$(addBlockSwitches);
$(globalSwitch);
</script>
</head>
@@ -133,6 +152,7 @@ $(addBlockSwitches);
<ul class="sectlevel2">
<li><a href="#_aws_lambda">AWS Lambda</a></li>
<li><a href="#_microsoft_azure">Microsoft Azure</a></li>
<li><a href="#_google_cloud_functions_alpha">Google Cloud Functions (Alpha)</a></li>
</ul>
</li>
</ul>
@@ -145,7 +165,7 @@ $(addBlockSwitches);
<p>Mark Fisher, Dave Syer, Oleg Zhurakousky, Anshul Mehra</p>
</div>
<div class="paragraph">
<p><strong>3.0.4.BUILD-SNAPSHOT</strong></p>
<p><strong>3.1.0.BUILD-SNAPSHOT</strong></p>
</div>
<hr>
</div>
@@ -1912,18 +1932,178 @@ $ mvn azure-functions:deploy</pre>
</td>
<td class="content">
The Azure sample app is written in the "non-functional" style (using <code>@Bean</code>). The functional style (with just <code>Function</code> or <code>ApplicationContextInitializer</code>) is much faster on startup in Azure than the traditional <code>@Bean</code> style, so if you don&#8217;t need <code>@Beans</code> (or <code>@EnableAutoConfiguration</code>) it&#8217;s a good choice. Warm starts are not affected.
:branch: master
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_google_cloud_functions_alpha"><a class="link" href="#_google_cloud_functions_alpha">Google Cloud Functions (Alpha)</a></h3>
<div class="paragraph">
<p>The Google Cloud Functions adapter enables Spring Cloud Function apps to run on the <a href="https://cloud.google.com/functions">Google Cloud Functions</a> serverless platform.
You can either run the function locally using the open source <a href="https://github.com/GoogleCloudPlatform/functions-framework-java">Google Functions Framework for Java</a> or on GCP.</p>
</div>
<div class="sect3">
<h4 id="_getting_started_3"><a class="link" href="#_getting_started_3">Getting Started</a></h4>
<div class="paragraph">
<p>Lets start with a simple Spring Cloud Function example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">@SpringBootApplication
public class CloudFunctionMain {
public static void main(String[] args) {
SpringApplication.run(CloudFunctionMain.class, args);
}
@Bean
public Function&lt;String, String&gt; uppercase() {
return value -&gt; value.toUpperCase();
}
}</code></pre>
</div>
</div>
<div class="sect4">
<h5 id="_test_locally"><a class="link" href="#_test_locally">Test locally</a></h5>
<div class="paragraph">
<p>Start by adding the Maven plugin provided as part of the Google Functions Framework for Java.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-xml hljs" data-lang="xml">&lt;plugin&gt;
&lt;groupId&gt;com.google.cloud.functions&lt;/groupId&gt;
&lt;artifactId&gt;function-maven-plugin&lt;/artifactId&gt;
&lt;version&gt;0.9.1&lt;/version&gt;
&lt;configuration&gt;
&lt;functionTarget&gt;org.springframework.cloud.function.adapter.gcloud.FunctionInvoker&lt;/functionTarget&gt;
&lt;port&gt;8080&lt;/port&gt;
&lt;/configuration&gt;
&lt;/plugin&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Specify your configuration main class in <code>resources/META-INF/MANIFEST.MF</code>.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code>Main-Class: com.example.CloudFunctionMain</code></pre>
</div>
</div>
<div class="paragraph">
<p>Then run the function:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>mvn function:run</pre>
</div>
</div>
<div class="paragraph">
<p>Invoke the HTTP function:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>curl http://localhost:8080/ -d "hello"</pre>
</div>
</div>
</div>
<div class="sect4">
<h5 id="_deploy_to_gcp"><a class="link" href="#_deploy_to_gcp">Deploy to GCP</a></h5>
<div class="paragraph">
<p>As of March 2020, Google Cloud Functions for Java is in Alpha.
You can get on the <a href="https://docs.google.com/forms/d/e/1FAIpQLScC98jGi7CfG0n3UYlj7Xad8XScvZC8-BBOg7Pk3uSZx_2cdQ/viewform">whitelist</a> to try it out.</p>
</div>
<div class="paragraph">
<p>First, add the Shade Plugin configuration to generate a fat jar when you run the <code>mvn package</code> command.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-xml hljs" data-lang="xml">&lt;plugin&gt;
&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
&lt;artifactId&gt;maven-shade-plugin&lt;/artifactId&gt;
&lt;executions&gt;
&lt;execution&gt;
&lt;phase&gt;package&lt;/phase&gt;
&lt;goals&gt;
&lt;goal&gt;shade&lt;/goal&gt;
&lt;/goals&gt;
&lt;configuration&gt;
&lt;shadedArtifactAttached&gt;true&lt;/shadedArtifactAttached&gt;
&lt;outputDirectory&gt;deploy&lt;/outputDirectory&gt;
&lt;shadedClassifierName&gt;gcp&lt;/shadedClassifierName&gt;
&lt;transformers&gt;
&lt;transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"&gt;
&lt;resource&gt;META-INF/spring.handlers&lt;/resource&gt;
&lt;/transformer&gt;
&lt;transformer implementation="org.springframework.boot.maven.PropertiesMergingResourceTransformer"&gt;
&lt;resource&gt;META-INF/spring.factories&lt;/resource&gt;
&lt;/transformer&gt;
&lt;transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"&gt;
&lt;resource&gt;META-INF/spring.schemas&lt;/resource&gt;
&lt;/transformer&gt;
&lt;transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/&gt;
&lt;transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"&gt;
&lt;mainClass&gt;com.example.CloudFunctionMain&lt;/mainClass&gt;
&lt;/transformer&gt;
&lt;/transformers&gt;
&lt;/configuration&gt;
&lt;/execution&gt;
&lt;/executions&gt;
&lt;/plugin&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Package the application.</p>
</div>
<div class="listingblock">
<div class="content">
<pre>mvn package</pre>
</div>
</div>
<div class="paragraph">
<p>You should see the fat jar in <code>deploy</code> directory.</p>
</div>
<div class="paragraph">
<p>Make sure that you have the <a href="https://cloud.google.com/sdk/install">Cloud SDK CLI</a> installed.</p>
</div>
<div class="paragraph">
<p>From the project base directory run the following command to deploy.</p>
</div>
<div class="listingblock">
<div class="content">
<pre>gcloud alpha functions deploy function-sample-gcp \
--entry-point org.springframework.cloud.function.adapter.gcloud.FunctionInvoker \
--runtime java11 \
--trigger-http \
--source deploy \
--memory 512MB</pre>
</div>
</div>
<div class="paragraph">
<p>Invoke the HTTP function:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>curl https://REGION-PROJECT_ID.cloudfunctions.net/function-sample-gcp -d "hello"</pre>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_sample_function"><a class="link" href="#_sample_function">Sample Function</a></h4>
<div class="paragraph">
<p>Go to the <a href="../../spring-cloud-function-samples/function-sample-gcp/">function-sample-gcp</a> to try out a sample function that you can test locally or deploy to GCP.</p>
</div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="js/tocbot/tocbot.min.js"></script>
<script type="text/javascript" src="js/toc.js"></script>
<link rel="stylesheet" href="js/highlight/styles/atom-one-dark-reasonable.min.css">
<link rel="stylesheet" href="js/highlight/styles/github.min.css">
<script src="js/highlight/highlight.min.js"></script>
<script>hljs.initHighlighting()</script>
</body>