Commit Graph

60 Commits

Author SHA1 Message Date
Oleg Zhurakousky
880333d394 GH-224 Added kotlin/java func composition test
Added test to make ure that Kotlin and Java functions are composable
Resolves #224
2018-10-26 16:16:57 +02:00
Oleg Zhurakousky
2e5c6d22b5 Added support for input Collection param
Added support for function parameter type Collection
Updated both Jackson and Gson mappers
Defined a new toObject() operation on JsonMapper and deprecated the old

Resolves #210
2018-10-25 12:47:41 +01:00
Dave Syer
54deae5dba Ensure FunctionalSpringApplication works with String sources 2018-10-23 14:03:43 +01:00
Oleg Zhurakousky
af717e445d Polishing
Resolves #219
2018-10-22 14:26:59 +02:00
Dave Syer
ba34d4b81b Add @FunctionalSpringBootTest and mini web server
User can run a minimal HTTP app using an app that is a Function
or an ApplicationContextInitializer. Can also test using
@FunctionalSpringBootTest in place of @SpringBootTest.

Add some tests and documentation for functional beans

Make server.address configurable
2018-10-22 14:26:17 +02:00
Dave Syer
c4ee7ab065 Add other annotation processors to functional context 2018-10-18 09:36:43 +01:00
Oleg Zhurakousky
ae07a13d03 GH-56 Added support for Function<Flux, Mono> and <Mono, Flux>
Resolves #56
Resolves #218
2018-10-17 21:14:27 -04:00
Oleg Zhurakousky
31e689b108 GH-208 polishing ec68f64 commit
Ensured that the composed Supplier is of type Mono<Void>
Fix tests
2018-10-14 20:29:13 -04:00
Oleg Zhurakousky
8c2fdfd193 GH-198 added multi-function validation test
Added test to validate that the behavior described in GH-198 is intentional and useful especially in light og GH-208
Resolves #198
2018-10-14 19:43:36 -04:00
Oleg Zhurakousky
ec68f6453c GH-208 Added support for composing Supplier and Consumer
This essentially returns a terminal Supplier - Supplier<Flux<Void>> which can no longer be composed with anything else
Resolves #208
2018-10-14 19:29:23 -04:00
Dave Syer
083d5e3bf3 Harmonize AWS and azure adapters 2018-10-12 17:10:13 +01:00
Andy Clement
2f9e4bb015 Adjust how classpath computed in test, for compatibility with Java 9+ 2018-10-09 17:11:26 -07:00
Oleg Zhurakousky
c43f081ef1 Cleanup and added more tests 2018-09-19 14:33:01 +02:00
Dave Syer
3c91914f82 Purge some more deprecated constructor usages 2018-09-17 15:21:40 +01:00
Dave Syer
f7b184c4c3 Revert to more convenient signature in FunctionCatalog 2018-09-17 15:07:24 +01:00
Oleg Zhurakousky
ca47076083 GH-205 Added initial Kotlin support documentation
polished tests and test configuration

Resolves #205
2018-09-11 11:39:24 +02:00
Oleg Zhurakousky
87c67427df GH-77 added initial Kotlin support
Added mixed java/kotlin POM configuration

added tests, javadocs

Resolves #77
Resolves #204
2018-09-11 11:37:13 +02:00
Oleg Zhurakousky
30187b583b GH-199 Added support for typeless lookup in FunctionCatalog
Updated both the interface as well as InMemoryFunctionCatalog BeanFactoryFunctionCatalog and SingleEntryFunctionRegistry implementations
Added tests

Resolves #199
2018-08-15 17:56:29 +02:00
Oleg Zhurakousky
ed14474b9f GH-191 Made 'name' required in FunctionRegistration 2018-07-30 13:48:48 +02:00
Oleg Zhurakousky
32ee27165b GH-190 Added null check for publisher
Resolves #190
2018-07-27 16:07:57 +02:00
Dave Syer
10b0413696 Omit optional generic information in tests 2018-07-05 14:02:25 +01:00
Dave Syer
94b1e56d55 Allow user to provide own Gson or ObjectMapper 2018-06-22 16:06:39 +01:00
Dave Syer
4c9627aee3 Fix Build and upgrade fully to Boot 2.0
Some tests still ignored.

Also adds draft functional bean registration support. The AWS sample
is using that now (it starts up 4x faster in AWS). To activate the
functional beans user has to supply a main class of type
ApplicationContextInitializer.
2018-06-21 17:57:50 +01:00
Dave Syer
00e2b749d2 First step in 2.0.0. Remove Stream dependencies 2018-06-21 06:35:41 +01:00
Dave Syer
66476559ed Move JsonMapper to spring-cloud-function-context
...in case it is needed elsewhere (see gh-151)
2018-05-21 08:50:35 +01:00
Dave Syer
e34324b5b4 Double check that a Function can return a Mono 2018-05-15 08:43:58 +01:00
Dave Syer
eaea89532c Add documentation for compiler configuration properties 2018-05-02 06:17:28 -04:00
Dave Syer
5aeba1ea96 Convert Consumer<Foo> to Function<Flux<Foo>,Mono<Void>>
This results in a better experience for users because the consumer
that they write is only applied to a Flux that is subscribed to
by the framework once. It gives better control over the flow of
foos, e.g. if some component wants to subscribe on a thread.
2018-03-26 10:06:13 +01:00
Dave Syer
a1b624b28a Inspect bean class if it is available
Avoids instantiating beans if not necessary, and allows user to
provide Function as a @SpringBootApplication (for instance), or
more generally as a source to the application context (as opposed
to being component scanned).
2018-03-21 11:09:57 +00:00
Dave Syer
773dddbe68 Ensure composite wrapper type reflects reality
When a Supplier<Flux<Foo>> is composed with a Function<Foo,Bar>
the resulting handler (supplier) should have Flux as its output
wrapper still (the most general output wrapper type in the chain).
2018-03-16 08:35:21 -04:00
Dave Syer
47f86671ca Allow pipe as well as comma in function composition 2018-03-16 08:05:29 -04:00
Dave Syer
5528659b4b Inspect bean definition more thoroughly for factory arguments
Fixes gh-153
2018-03-02 11:28:33 +00:00
Dave Syer
dc008cc24d Ensure a function is inspectable as itself and its wrapper
Since a function is wrapper in a FluxWrapper (and possibly also
an Isolated), the link is lost between the bean and the type
metadata without this change.
2018-03-01 09:10:14 +00:00
Dave Syer
33b33adb4b Change FunctionCatalog to key off Class<?>
Makes it possible to support other "function" types in the future.
The user is always taking a risk with the lookup that the object
returned has the generic type desired (but that hasn't changed
with this commit). FunctionCatalog is a lot simpler as a result
and also a lot more flexible.
2018-02-28 14:18:09 +00:00
Dave Syer
616e2825c6 Move FunctionCatalog into context module 2018-02-27 09:05:28 +00:00
Dave Syer
7bc6d7dfee Re-order type discovery and function wrapping
Otherwise the explicit types from the function registration are
not used.
2018-02-26 16:28:50 +00:00
Dave Syer
5203401e00 Use Void as input type for Supplier, etc. 2018-02-26 14:15:54 +00:00
Dave Syer
f9e4546070 Add convenience methods to FunctionType 2018-02-26 11:45:01 +00:00
Dave Syer
38f6caf4dc Add FunctionType abstraction and test it 2018-02-26 09:56:02 +00:00
Dave Syer
ccd3953163 Cache result of isMessage() computation before function is wrapped
Otherwise you get the wrong result when you go back and ask later
(but only if the bean is a singleton with no bean definition).
2018-02-14 16:25:12 +00:00
Dave Syer
c728cd4c01 Support for Function<Publisher<...>,...> 2018-02-14 14:09:28 +00:00
Dave Syer
1af0d451cf Migrate to servlet binder for web features 2018-01-03 15:06:33 +00:00
Artem Bilan
46fdca479b Properly resolve FactoryBean for function
Fixes: gh-118

When the `BeanDefinition` for `Function` is a `FactoryBean`
(e.g. `GatewayProxyFactoryBean` in Spring Integration) and that
`BeanDefinition` isn't registered as `@Bean` method (e.g.
Spring Integration Java DSL parser), the `ContextFunctionCatalogAutoConfiguration`
doesn't resolve the target `Function` type properly

* Get the target `Function` bean type via `BeanFactory.getType(String)`
* Make fallback to the `Object.class` instead of bean type since we are
expecting here a generic type anyway
2017-12-01 10:31:18 +00:00
Dave Syer
e824fbf6cb Isolate the context class loader if function appears to need it
When a function is created using an isolated class loader it might
want to use that class loader again for its invocations, and a lot
of tools (Spring etc.) use the context class loader for that kind
of thing if they don't have an explicit default value. So we
set the context class loader before, and unset it after, the
function invocation using a convenience wrapper.
2017-11-25 05:25:29 +09:00
Dave Syer
f3951cba66 Prefer explicit route to default 2017-11-24 13:21:08 +09:00
Dave Syer
1ee517ab01 Use unique function if there is only one and name not provided
If the user doesn't ask for a specific function, but there is only
one possible choice, we can just use that.
2017-11-24 12:41:10 +09:00
Dave Syer
8459fb4e30 Ensure a concrete type with parametrric subtype is detected
If user defines their own @Beans from conrete types that implement
Function<...> then their type signature is detectable from the
class.
2017-11-20 15:34:06 +00:00
Dave Syer
219d056801 Add FunctionRegistry interface (writable FunctionCatalog)
This makes dynamic function registration (after context starts) much
easier. Also frees us from having to employ BeanFactoryPostProcessor
and other tricks to get the functions registered on startup.
2017-11-13 14:13:59 +00:00
Dave Syer
41d1dfa6bc Add public registration method to bean post processor
Also simplifies logic of looking up message types
2017-11-13 09:27:36 +00:00
Dave Syer
d4b87c1fe7 Initial support for composable functions
There's a test for each of the supported types. No error handling
yet.

Fixes gh-122
2017-11-10 16:45:11 +00:00