Commit Graph

76 Commits

Author SHA1 Message Date
Dave Syer
d95ab8f173 Migrate type computation logic to FunctionType 2018-02-26 10:57:45 +00:00
Dave Syer
38f6caf4dc Add FunctionType abstraction and test it 2018-02-26 09:56:02 +00:00
Dave Syer
bf41055dc7 Some dependency hygiene and update to Boot 1.5.10
The web module doesn't really need to depend on tomcat and all of
the Spring Boot web stack, but users need a way to grab that stuff
quickly if they want it (hence the new starter).

Also removed all spring-boot-starter dependencies from core and
context modules.
2018-02-23 12:12:06 +00:00
Dave Syer
a2a2932715 Revert to snapshots 2018-02-21 07:24:21 +00:00
Dave Syer
72efd58675 Update to 1.0.0.M4 2018-02-20 19:25:11 +00:00
Dave Syer
8cd2675986 Add tests for various scenarios of message conversion 2018-02-16 10:31:28 +00:00
Dave Syer
1b624c3531 Support for isolated class loaders extended to cover more functions
Functions with Flux and Message (as well as POJOs and Flux of POJO
which were already supported) should now work if they are created in
an isolated class loader. Preconditions:

* The class loaders must have the reactor-core (and reactive-streams)
shared between the app and the function. Practically speaking this means
there has to be a parent class loader with just reactive types, and
sibling children for the app and the function. This is not a new
requirement (it was needed for Flux of POJO anyway).

* Message types are handled reflectively, so they don't have to be in a
shared class loader. But they do have to be  on the class path on
both sides (obviously).
2018-02-16 08:16:55 +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
73098244e3 Revert to snapshots 2018-01-20 11:57:49 +00:00
Dave Syer
77e0a5c514 Update to 1.0.0.M3 2018-01-19 13:55:34 +00:00
Dave Syer
8a65cabb90 Remove unnecessary dependencies 2018-01-05 16:18:27 +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
47fd4c3ed2 Going back to snapshots 2017-12-01 10:31:18 +00:00
Dave Syer
b6310e1811 Update SNAPSHOT to 1.0.0.M2 2017-11-28 13:40:35 +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
85ba0b480e Fallback to Object.class not the function type
See gh-118 (partial fix)
2017-11-10 17:38:45 +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
Dave Syer
ad0ebd5cfc Add additional logic to function catalog to help with singletons
A registered singleton doesn't have a BeanDefinition, but it might have
a compiled type with enough generic information to pull out the
input and output types.
2017-11-10 12:11:55 +00:00
Dave Syer
a27f1fe4dd Switch on @FunctionScan by default 2017-10-25 08:53:14 +01:00
Dave Syer
af8b6e253e Revert to snapshots 2017-09-15 17:49:31 +01:00
Dave Syer
858b7404c6 Update to 1.0.0.M1 2017-09-15 17:48:51 +01:00
Dave Syer
3ccb925733 Merge core packages into one 2017-09-15 17:10:00 +01:00
Dave Syer
61a902ce9a Add spring-cloud-function-dependencies and use it throughout 2017-09-15 09:34:44 +01:00
Eric Bottard
aa45ff4b94 Revert visibility of FunctionRegistration to public
Fixes #102
2017-08-24 19:21:29 +02:00
Oleg Zhurakousky
a973b678f1 FunctionUtils polishing
- attempted to make code more functional (eat our own dog food) and concise
- addressed PR comment
- additional cleanup/polishing of FunctionUtils and related classes
- Removed Function/Supplier/ConsumerProxy classes by extending type info on their super interface
- Renamed FunctionUtils to FunctionFactoryUtils
- Added javadoc to FunctionFactoryUtils to explain its design considerations as well as what it can and can not doi

Fixes gh-90
2017-08-22 14:07:42 +01:00
Oleg Zhurakousky
592eef9d52 General polishing
- minor refactoring of FunctionRegistration and some javadoc
 - general cleanup of ContextFunctionCatalogAutoConfiguration (mainly consolidated repeatable code)

Fixes gh-98
2017-08-22 10:34:13 +01:00
Oleg Zhurakousky
182317dbe9 Minor polishing of InMemoryFunctionCatalog
- Removed constructor in InMemoryFunctionCatalog that creates empty maps and no registrations since there is no way to register anything after catalog is created.
- Refactored registration logic a bit more functional/concise in the FunctionRegistration constructor of InMemoryFunctionCatalog
- Added additional assertions in tests

rebased and removed the assertion that was causing certain test failures
2017-07-13 16:07:53 +01:00
Dave Syer
c8646d64d8 Strangle old inspector methods
Fixes gh-81
2017-07-13 13:37:45 +01:00
Dave Syer
d7d49858f6 Add new methods to FunctionInspector 2017-07-13 13:37:06 +01:00
Dave Syer
7e966c73ca Adds routing keys in message headers
If the incoming message has a stream_routekey header, we use that
to route the message to a named function. Also adding the header
to messages coming out of suppliers.

The biggest change here is sort of orthogonal: it fixes a bug where
Spring Integration would subscribe twice to the same input channel
if the FunctionCatalog contains both functions and consumers. Then
when a message comes in it is dispatched to one or the other, but not
both. So the routing key couldn't work without fixing that
problem.
2017-07-13 13:32:32 +01:00
Dave Syer
4b30721d02 Fix naming indirection so that input types are correctly located
Also applies to output types, wrapper types and identifying if
messages can be processed directly.

See gh-81 (the ambiguity is still there, but the indirection bug
is fixed).
2017-07-11 17:39:42 +01:00
Dave Syer
da0c954135 Add get*Names() to FunctionCatalog
We could go wit a separate interface, but it seems sensible to
keep it together really, so that callers don't have to downcast.
2017-06-29 14:43:19 +01:00
Dave Syer
d826884d02 Ensure @Component scanned from jar on classpath can be inspected
And test it using a new POF sample.
2017-06-28 17:52:37 +01:00
Dave Syer
f94d672dc4 Add test and fix type inspection for scanned functions
Fixes gh-73
2017-06-28 11:00:07 +01:00
Dave Syer
0756dc3394 Add support for Message<Foo> in stream apps
The FunctionInspector needs to be able to distinguish between a
function of Flux<Foo> and a function of Flux<Message<Foo>>. Then
it can do the conversion a level below.

Only supports Message->Message or POJO->POJO (no mixtures), so there
is only one new method in FunctionInspector.

No support in the web endpoints yet. But it's probably not so hard
to add.
2017-06-15 12:32:46 +01:00
Dave Syer
14867f9685 Add defensive null check 2017-06-07 14:46:59 +01:00
Dave Syer
9bf3601143 Fixed consumer sample to accept bare string 2017-05-26 12:51:56 +01:00
Dave Syer
99c7b995e0 Add FunctionFactoryMetadata interface for type discovery
The compiled functions implement that interface which means you can inspect
the signature of the method that created them and discover its
generic types.
2017-05-26 10:09:47 +01:00
markfisher
841d4cdf48 fix compiled consumer sample 2017-05-25 09:27:49 -04:00
Dave Syer
c685866f09 Fix compiled scripts demo from README
Compiled functions always show up with no metadata, and you can only
guess what the types are from the bean definition. Probably we should
add more information to the bean definition if we have it when we
compile the function.

There is still a problem if user defines functions that are not of
Flux<String> (but that has always been the case).
2017-05-25 07:53:29 +01:00
Dave Syer
5589804d2c Add support for single valued Supplier as well 2017-05-24 11:00:32 +01:00
Dave Syer
0d2418a47b Add "wrapper" type methods to FunctionInspector
These can be used to more reliably discover whether the user
has declared a function with flux types or "bare" POJOs. They
then pave the way to supporting single valued types in a special
way.

Also consolidate and simplify the logic in FunctionInspector
2017-05-24 09:10:46 +01:00
Dave Syer
998ea3ad35 Fix and test bug with generic input or output types
Without this fix a Function<Foo<Bar>,...> shows as having an
input type of Bar - we need to only take the parameter if the
raw type is Flux.
2017-05-22 13:27:49 +01:00