Commit Graph

164 Commits

Author SHA1 Message Date
Dave Syer
2dd7dfb900 Tweak logic in stream invokers
* If there is only one function, use it unconditionally
* If no functions match, ensure that null is not the selector
* If a conversion succeeds, check the type of the result
2017-06-29 14:29:01 +01:00
Dave Syer
cf707fd872 Update thin launcher to 1.0.5 2017-06-29 08:50:33 +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
d1ccef62b5 FunctionHandlerMapping needs to be defensive with debug flag
Spring Boot apps often run with --debug (no boolean value), so
we need to be defensive and not barf if it's empty (and therefore
not convertible to a boolean)
2017-06-28 15:07:07 +01:00
Dave Syer
78ca4df128 Update CI pipeline with new repo location 2017-06-28 11:27:17 +01:00
Dave Syer
5243057d2a Skip deployment of samples 2017-06-28 11:07:47 +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
e4b181d0c4 Fix /prefix test so it asserts a 404 as well as a 200 2017-06-28 09:41:04 +01:00
Dave Syer
b9eb46c7bd Update thin launcher to 1.0.4 2017-06-27 09:47:43 +01:00
Dave Syer
eb8d865bd1 Update openwhisk README to use sample from the project
The io.spring sample referred to in the openwhisk README isn't
in this repo, so users generally don't have it installed locally.
This change makes it more obvious that you have to create your
own.

Also fixes the `wsk ...` command lines (the order of arguments
was wrong - maybe the CLI changed?).
2017-06-26 12:19:21 -04:00
Dave Syer
b61562508b Add support for Message handling in web functions
If the output is a Message we grab the headers from the first one
and send those as response headers.

A function can add headers to messages. The HTTP response will
contain only headers that are in x-* _or_ were added to the message
by user (i.e. they weren't in the request).
We certainly do not want to pass through all HTTP headers (request
headers can conflict with or invalidate response headers).
2017-06-22 09:45:12 +01:00
Dave Syer
1d53cd1234 Ensure debug flag gets resolved in controller 2017-06-22 09:45:12 +01:00
markfisher
9d0cf75bff initial commit for openwhisk support 2017-06-16 09:43:10 -04: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
markfisher
797936fd0c add README for AWS adapter 2017-06-07 19:05:36 -04:00
Dave Syer
347cfcef03 Add concourse pipeline 2017-06-07 12:50:50 -04:00
Dave Syer
14867f9685 Add defensive null check 2017-06-07 14:46:59 +01:00
Dave Syer
d641aae494 Make spring.cloud.function.stream.endpoint optional for stream apps
If there is only one function you shouldn't have to set any configuration
to get a stream app to run. This also implementation supports multiple
functions, trying to guess which one to use based on the type of
the incoming message payload. In principle that could be strategized
as a simple router function (e.g. to look for a header with a function
name).

If there are functions and consumers in the same app, they will
subscribe to the same input channel (and hence by default Spring
Integration will load balance between them). This could also probably
use some more features, to specify the desired behaviour.

If user *does* supply spring.cloud.function.stream.endpoint then it
is used and overrides all other possible routes.
2017-06-02 18:11:25 -04:00
markfisher
9d0d04f4f6 updated task sample for consumer change 2017-05-26 15:26:25 -04:00
Dave Syer
9bf3601143 Fixed consumer sample to accept bare string 2017-05-26 12:51:56 +01:00
Dave Syer
2a4c46f57b Remove unused methods in compiled functions 2017-05-26 10:28:43 +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
5a7c95bd97 add type info for compiled functions 2017-05-25 12:38:54 -04:00
Dave Syer
098c77279b Revert AWS sample to use logback 2017-05-25 15:40:10 +01:00
Dave Syer
f843821ebe Make adapter parent deployable 2017-05-25 15:40:10 +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
41b1a6584e Add logging config for AWS sample 2017-05-24 14:31:41 +01:00
Dave Syer
87f077954e Try to detect single-valued returns in AWS
Lambdas generally only deal with single values anyway, but for
consistency we should return similar results from a Lambda handler
as from an MVC handler in s-c-f-web.
2017-05-24 13:27:10 +01:00
Dave Syer
5589804d2c Add support for single valued Supplier as well 2017-05-24 11:00:32 +01:00
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