Commit Graph

134 Commits

Author SHA1 Message Date
Dave Syer
20a6796793 Add support for rendering single value in response
If the request is a single value, we already know, so if we also
know that the function returned a single-valued type, then we can
render the single value, instead of an array with a single item.

See gh-36
2017-05-24 10:16:22 +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
markfisher
719237e9c7 add adapters as child module 2017-05-23 16:30:18 -04:00
markfisher
78a37ef8ad avoid NullPointerException for warning diagnostic 2017-05-23 08:08:41 -04: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
6e1f0b9a6e Add FunctionInspector to deployer so types can be inspected
ALso added a bunch of DEBUG logging because it's hard to debug the
deployer app.

Fixed gh-53
2017-05-22 10:57:47 +02:00
Dave Syer
3606e51d78 Fix deployer app
Run it, then

$ curl localhost:8080/admin
{"sample":{"name":"sample","id":"81c568e36c7909ec1dd841aa7ee6d3e3","path":"..."}}

undeploy:

$ curl localhost:8080/admin/sample -X DELETE
{"id":"81c568e36c7909ec1dd841aa7ee6d3e3"}

redeploy

$ curl localhost:8080/admin/sample -d path=maven://com.example:function-sample-pojo:1.0.0.BUILD-SNAPSHOT
{"id":"81c568e36c7909ec1dd841aa7ee6d3e3"}

(Takes about 500ms)
2017-05-19 11:29:03 +02:00
markfisher
56b9be9b6e add task sample 2017-05-17 22:35:10 -04:00
Dave Syer
120d2da496 Add support for POSTing a single POJO
You need to cache the request body so it can be read twice, once
to see if it's an array, and again to turn it into a POJO.
2017-05-16 10:26:10 +01:00
markfisher
ff78bfc438 ensure processor is initialized when getting type 2017-05-05 09:44:27 -04:00
markfisher
f6355df58d added rabbit binder dependency to sample 2017-05-05 09:20:03 -04: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
e2c257b3e7 Fix sample so the thin.profile=stream works 2017-04-27 12:33:08 +01:00
Dave Syer
995a12b234 Add forwarded header in gateway 2017-04-27 12:09:21 +01:00
Marius Bogoevici
e117cfd5bd Tentatively fix streaming issues
* Assume that the Function returned by FunctionCatalog
  is already wrapped as Function<Flux<?>,Flux<?>>
2017-04-27 07:34:24 +01:00
Dave Syer
f02f2eaf95 Remove unused annotation class 2017-04-25 11:47:50 +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
Marius Bogoevici
4a1972dcf1 Add conversion support for Stream 2017-04-25 08:28:38 +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
Dave Syer
5055369cb5 Fix prefix issue 2017-04-24 16:31:09 +01:00
Dave Syer
b80ce1fb3e Update to latest reactor 2017-04-19 10:23:24 +01:00
Dave Syer
36c6b2dba7 Update versions of boot things 2017-04-12 17:57:28 +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
d1cf9b47a4 Add some failing tests 2017-04-05 13:40:24 +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
Marius Bogoevici
82e19894b2 Add stream-function tests 2017-04-04 00:25:12 -04:00
markfisher
d208b5e0f3 stream consumer invoker target now expects Flux 2017-03-31 12:09:04 -04:00
markfisher
0b49edc2fd polishing 2017-03-31 11:43:28 -04:00
Dave Syer
3b598bd10c Break up comments in javadocs 2017-03-31 09:58:24 -04:00
Dave Syer
cea87fb8c0 Include cause in rethrown exception 2017-03-31 09:58:24 -04:00
Dave Syer
4346a7adc8 Re-use get, post, put etc. in overloaded methods 2017-03-31 09:58:24 -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
07c9d1c460 Remove unused method parameter 2017-03-31 13:56:25 +01:00
Dave Syer
38dcbaffff Add test for priority of looking up supplier in GET mapping 2017-03-31 13:48:36 +01:00
Dave Syer
cadd5546da Add custom HandlerMapping to allow more flexible request mapping 2017-03-31 13:44:11 +01:00
Dave Syer
787ab65d55 On POST to a Consumer, reflect input and send 202 2017-03-30 16:42:19 +01:00
Dave Syer
0d08735dda Test POST to Consumer
See gh-36
2017-03-30 16:42:19 +01:00
Dave Syer
8aefd9b472 Make rest template builder optional 2017-03-30 16:42:02 +01:00
Dave Syer
5162e6b149 Add gateway library for building micro-proxies 2017-03-27 10:42:05 +01:00
markfisher
98c2ca76f5 avoid Supplier NPE 2017-03-18 21:38:08 -04:00
Dave Syer
da013c1015 Purge warnings in IDE 2017-03-14 18:21:41 +00:00
Dave Syer
915ff401be Make GET /{function}/{value} single valued (Mono)
When the user has sent us a single value, we can make the signature
of the handler and the format of the HTTP response much more
natural if it is single valued too (i.e. a Mono).
2017-03-13 15:01:10 +00:00
Dave Syer
9b24d23df8 Add configurable base path for web resources 2017-03-13 13:43:26 +00: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
Dave Syer
17b644f563 If HTTP client asks for JSON, then time out the response
An HTTP response does not have to be an infinite stream, and in fact
life is simpler if it is not. The timeout in the web wrappers can
be used to close the response and return normally to a client
that has been waiting more than (say) 1s, instead of treating
it as an error condition.

Error handling is still kind of unsolved.
2017-03-09 16:10:08 +00:00
Dave Syer
ec097a563d Tweak SSE emitter a bit so that it handles empty responses
An empty response should either be empty or complete JSON. I went
for the latter.
2017-03-08 15:02:35 +00:00
Dave Syer
0c4dcfaf72 Fix bug in response when JSON is empty 2017-03-07 16:54:34 +00:00
markfisher
6044b053ae renamed property keys 2017-03-03 16:35:30 -05:00