From 289576ab91b668ca69d816887e28c9ae23b8d527 Mon Sep 17 00:00:00 2001
From: buildmaster
The sample @SpringBootApplication 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.
The @Beans can be Function, Consumer or Supplier (all from
-java.util), and their parametric types can be String or POJO.
Functions can also be of Flux<String> or Flux<Pojo> 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. There is also support for Message<Pojo> where the
-message headers are copied from the incoming event, depending on the
-adapter. The web adapter also supports conversion from form-encoded
-data to a Map, and if you are using the function with Spring Cloud
-Stream then all the conversion and coercion features for message
-payloads will be applicable as well.
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.
-3.0.0.BUILD-SNAPSHOT
+3.0.1.BUILD-SNAPSHOT
The AWS adapter takes a Spring Cloud Function app and converts it to a form that can run in AWS Lambda.
@@ -376,7 +376,7 @@ we will not attempt any conversion and will pass the raw input directly to a funYour functions will start much quicker if you can use functional bean definitions instead of @Bean. To do this make your main class
an ApplicationContextInitializer<GenericApplicationContext> and use the registerBean() methods in GenericApplicationContext to
-create all the beans you need. You function need sto be registered as a bean of type FunctionRegistration so that the input and
+create all the beans you need. You function need to be registered as a bean of type FunctionRegistration so that the input and
output types can be accessed by the framework. There is an example in github (the AWS sample is written in this style). It would
look something like this:
3.0.0.BUILD-SNAPSHOT
+3.0.1.BUILD-SNAPSHOT
The Azure adapter bootstraps a Spring Cloud Function context and channels function calls from the Azure framework into the user functions, using Spring Boot configuration where necessary. Azure Functions has quite a unique, but invasive programming model, involving annotations in user code that are specific to the platform. The easiest way to use it with Spring Cloud is to extend a base class and write a method in it with the @FunctionName annotation which delegates to a base class method.
The sample @SpringBootApplication 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.
The @Beans can be Function, Consumer or Supplier (all from
-java.util), and their parametric types can be String or POJO.
Functions can also be of Flux<String> or Flux<Pojo> 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. There is also support for Message<Pojo> where the
-message headers are copied from the incoming event, depending on the
-adapter. The web adapter also supports conversion from form-encoded
-data to a Map, and if you are using the function with Spring Cloud
-Stream then all the conversion and coercion features for message
-payloads will be applicable as well.
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.
-3.0.0.BUILD-SNAPSHOT
+3.0.1.BUILD-SNAPSHOT
The reference documentation consists of the following sections:
diff --git a/reference/html/openwhisk.html b/reference/html/openwhisk.html index 347a86b78..a3d9d1ef6 100644 --- a/reference/html/openwhisk.html +++ b/reference/html/openwhisk.html @@ -103,7 +103,7 @@ $(addBlockSwitches);3.0.0.BUILD-SNAPSHOT
+3.0.1.BUILD-SNAPSHOT
The OpenWhisk adapter is in the form of an executable jar that can be used in a a docker image to be deployed to Openwhisk. The platform works in request-response mode, listening on port 8080 on a specific endpoint, so the adapter is a simple Spring MVC application.
diff --git a/reference/html/spring-cloud-function.html b/reference/html/spring-cloud-function.html index 9dab8e722..58399d2b2 100644 --- a/reference/html/spring-cloud-function.html +++ b/reference/html/spring-cloud-function.html @@ -98,14 +98,15 @@ $(addBlockSwitches);Mark Fisher, Dave Syer, Oleg Zhurakousky, Anshul Mehra
3.0.0.BUILD-SNAPSHOT
+3.0.1.BUILD-SNAPSHOT
The sample @SpringBootApplication 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.
The @Beans can be Function, Consumer or Supplier (all from
-java.util), and their parametric types can be String or POJO.
Functions can also be of Flux<String> or Flux<Pojo> 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. There is also support for Message<Pojo> where the
-message headers are copied from the incoming event, depending on the
-adapter. The web adapter also supports conversion from form-encoded
-data to a Map, and if you are using the function with Spring Cloud
-Stream then all the conversion and coercion features for message
-payloads will be applicable as well.
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.
-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 FunctionCatalog, using primitives
-defined by the Project Reactor (i.e., Flux<T> and Mono<T>).
-Users can supply a bean of type Function<String,String>, for instance, and the FunctionCatalog will wrap it into a
-Function<Flux<String>,Flux<String>>.
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.
+That’s why all user defined functions are transformed into a canonical representation byFunctionCatalog.
While users don’t normally have to care about the FunctionCatalog at all, it is useful to know what
kind of functions are supported in user code.
It is also important to understand that Spring Cloud Function provides first class support for reactive API
+provided by Project Reactor allowing reactive primitives such as Mono and Flux
+to be used as types in user defined functions providing greater flexibility when choosing programming model for
+your function implementation.
+Reactive programming model also enables functional support for features that would be otherwise difficult to impossible to implement
+using imperative programming style. For more on this please read Function Arity section.
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 Flux of the same type. If the user writes
-a function using Message (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.
Spring Cloud Function embraces and builds on top of the 3 core functional interfaces defined by Java +and available to us since Java 8.
+Supplier<O>
+Function<I, O>
+Consumer<I>
+| User Function | -Catalog Registration | -- |
|---|---|---|
|
-
|
-- |
|
-
|
-- |
|
-
|
-- |
|
-
|
-- |
|
-
|
-- |
|
-
|
-- |
|
-
|
-- |
|
-
|
-- |
As you can see from the table above Supplier can be reactive - Supplier<Flux<T>>
+
Supplier can be reactive - Supplier<Flux<T>>
or imperative - Supplier<T>. From the invocation standpoint this should make no difference
to the implementor of such Supplier. However, when used within frameworks
(e.g., Spring Cloud Stream), Suppliers, especially reactive,
@@ -477,19 +403,6 @@ a controlled way.
Spring Cloud Function will scan for implementations of Function,
-Consumer and Supplier in a package called functions if it
-exists. Using this feature you can write functions that have no
-dependencies on Spring - not even the @Component annotation is
-needed. If you want to use a different package, you can set
-spring.cloud.function.scan.packages. You can also use
-spring.cloud.function.scan.enabled=false to switch off the scan
-completely.
Function Composition is a feature that allows one to compose several functions into one. @@ -613,6 +526,56 @@ values (e.g., Message).
There are times when a stream of data needs to be categorized and organized. For example, +consider a classic big-data use case of dealing with unorganized data containing, let’s say, +‘orders’ and ‘invoices’, and you want each to go into a separate data store. +This is where function arity (functions with multiple inputs and outputs) support +comes to play.
+Let’s look at an example of such a function (full implementation details are available +here),
+@Bean
+public Function<Flux<Integer>, Tuple2<Flux<String>, Flux<String>>> organise() {
+ return flux -> ...;
+}
+Given that Project Reactor is a core dependency of SCF, we are using its Tuple library. +Tuples give us a unique advantage by communicating to us both cardinality and type information. +Both are extremely important in the context of SCSt. Cardinality lets us know +how many input and output bindings need to be created and bound to the corresponding +inputs and outputs of a function. Awareness of the type information ensures proper type +conversion.
+Also, this is where the ‘index’ part of the naming convention for binding
+names comes into play, since, in this function, the two output binding
+names are organise-out-0 and organise-out-1.
| + + | +
+IMPORTANT: At the moment, function arity is only supported for reactive functions
+(Function<TupleN<Flux<?>…>, TupleN<Flux<?>…>>) centered on Complex event processing
+where evaluation and computation on confluence of events typically requires view into a
+stream of events rather than single event.
+ |
+
We also provide support for Kotlin lambdas (since v2.0). @@ -647,6 +610,19 @@ same rules for signature transformation outlined in "Java 8 function support" se autoconfiguration and supporting classes.
Spring Cloud Function will scan for implementations of Function,
+Consumer and Supplier in a package called functions if it
+exists. Using this feature you can write functions that have no
+dependencies on Spring - not even the @Component annotation is
+needed. If you want to use a different package, you can set
+spring.cloud.function.scan.packages. You can also use
+spring.cloud.function.scan.enabled=false to switch off the scan
+completely.