Howdy Folks,
I just got back from having an amazing time at SpringIO 2019 in Barcelona. Since I have a close affinity with the ‘serverless’ concept Spring-Cloud-Function
particularly caught my attention.
I will undoubtedly write a longer blogpost. I missed my flight this morning (not drunk just tired) so I had some time to kill. Here is a teaser already.
Enter Spring
You can now use Spring to implement your business logic via ‘serverless’ infrastructure. How amazing is that!?
Using the Spring framework will bring all the goodness like Dependency Injection and auto configuration to the serverless landscape. It was not impossible before (think eg Dagger). But for many developers using the Spring framework will feel familiar. That will lower the threshold to serverless.
The basic idea is that you run the logic of your serverless function by using a Function
, Consumer
or Supplier
interface. You will do this by:
- either creating a bean that has a type of
Function
,Consumer
orSupplier
interface - or having a class implement this interface
Pointers
No, not those things with the memory addresses. Just a couple of things that I found worth mentioning while I was developing a POC:
- you have to build your application as a shaded jar
- you can define multiple Spring Cloud Functions in your project.
- you need to specify which function has to be invoked using the property
function.name
- If you create classes that implement one of the interfaces you must specify where spring boot has to look for the functions with the
spring.cloud.function.scan.packages
property
- If you create classes that implement one of the interfaces you must specify where spring boot has to look for the functions with the
- you need to specify which function has to be invoked using the property
- The spring-boot-thin-layout dependency helps keeping your artefact small
- you can run the application locally
- adding a dependency
spring-cloud-function-adapter-aws
- use the
Greenwich
release of Spring Cloud with Spring boot 2.1.* if you start a project now.
Are you triggered to know more??
> keep a close eye on https://ordina-jworks.github.io/ where an extended blogpost will follow later.