Commit Graph

51 Commits

Author SHA1 Message Date
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
Dave Syer
69c22482d1 Add more subtle content negotiation in web layer
So that single Strings can be POSTed without JSON conversion.
There's still some work to do to support single POJOs in JSON, and
to reach parity with the WebFlux reactive type handlers, but it's
now closer to what we had before we moved the String conversion
out of the function layer.
2017-05-05 09:22:23 +01:00
Dave Syer
39ca7952b9 Fix some tests
There is one behaviour change (you have to POST an array to a function
endpoint if you are sending a body), and also a message converter that
needed to be removed so that arrays are not toStringed in the response
body.
2017-04-25 08:51:31 +01:00
Dave Syer
4686e450b1 Alternative approach to MVC handling
Doesn't rely on manipulating the FunctionCatalog, and does type
conversion/coercion in the MVC layer.
2017-04-24 16:31:09 +01:00
Marius Bogoevici
70dff6bb6b Enable JSON conversion for non-Flux functions
- use ProxyWrapper around a FluxConsumer as well
  making it consistent with the behaviour of Flux
  functions
- Enable introspection for scanned beans
- Fix failing tests by passing JSON string as input messages
  (marshalled form expected from the binder)
2017-04-06 08:24:51 +01:00
Dave Syer
d67159729d Add support for explicit FunctionRegistration
A bean of type FunctionRegistration registers the function with
user-specified name and other properties, rather than relying on the
bean name.

Alternatively, function catalog keys can be specified as a
@Qualifier, which will be used instead of the bean name if
no registration is found.
2017-04-04 10:24:54 -04:00
markfisher
0b49edc2fd polishing 2017-03-31 11:43:28 -04:00
Dave Syer
2b88eaeb08 Extend support for simple types to Consumer and Supplier
The function catalog now always wraps beans that deal with non-flux
generic types.
2017-03-31 14:08:35 +01:00
Dave Syer
cadd5546da Add custom HandlerMapping to allow more flexible request mapping 2017-03-31 13:44:11 +01:00
Oleg Zhurakousky
2a0653b0e7 Removed redundant entries from POM files
Polished POM files to remove redundant entries that were causing warnings in the IDE. Some notable changes are:
- Removed spring-boot.version from sample project as they inherit it from the parent
- Removed versioning for maven-jar-plugin (was 3.0) from multiple project so it relies on the managed version
- Removed java.version from all spring-cloud-function-* modules as they inherit the one from parent.

Addressed PR comments
- removed references to maven-jar-plugin
2017-03-11 18:31:32 -05:00
Dave Syer
5ace9b764b Resort to reflection if the function is not a @Bean
Beans that are not created from a @Bean factory method do not have
the same kind of metadata. This change uses relection to extract
the target type from the bean definition if all else fails.
2017-03-10 17:40:05 +00:00
Dave Syer
2ee97721ab Support HTTP GET of single value value Function
E.g. a Function<Long, Foo> can be used to fetch a single entity of
type Foo with a long ID., via /{function}/{id}
2017-03-10 16:33:34 +00:00
markfisher
1dc0489c23 introspect bean definition for Flux types
non-Flux Functions wrapped during auto-config
2017-03-02 10:53:21 -05:00
Dave Syer
bcef4e1600 Remove unused property 2017-02-24 16:58:52 +00:00
markfisher
b4c37f7828 added FunctionScan annotation 2017-02-20 12:20:42 -05:00
markfisher
0a6dce951b add support for function composition 2017-02-06 15:55:53 -05:00
markfisher
cc3bb8f645 renamed ApplicationContextFunctionCatalog 2017-01-13 10:45:07 -05:00
Dave Syer
216e5c9207 Add MVC body processors to handle Flux
We don't need to cover all the possible uses of Flux (only
Flux<String> really), so this isn't comprehensive coverage of
all the features in Spring WebFlux, but it's good enough for
functions to run with Spring Boot 1.5.
2017-01-12 08:55:46 -05:00
markfisher
cfd416590d removing FileSystemFunctionRegistry 2017-01-11 20:59:18 -05:00
Dave Syer
b3750cdfa5 Check for simple String inputs and don't convert them 2017-01-10 15:27:42 -05:00
Dave Syer
9321dc7311 Remove function composition from the catalog interface
Should be easy enoug hto add back later, but it was causing issues
with type conversion where we are npot yet sophisticated enough
to chain functions together and keep track of the types being
passed between them.
2017-01-10 12:37:29 -05:00
Dave Syer
3357a93cef Add some tests for JSON mime types in rest endpoints 2017-01-06 14:11:48 +00:00
Dave Syer
91717ec9a6 Convert functions etc. after context starts
The app deployer now has to reach into the function contexts and
extract a catalog and call its methods reflectively.
2017-01-04 17:48:13 +00:00
Dave Syer
13774abe39 Remove unnecessary parameters 2017-01-04 09:34:09 +00:00
Dave Syer
80408d2f77 Add support for consumers and factor out base class 2017-01-04 09:30:23 +00:00
Dave Syer
f8a5f02be3 Add POJO sample and switch to using that for testing 2017-01-03 17:48:57 +00:00