SlideShare uma empresa Scribd logo
1 de 20
Baixar para ler offline
Serverless functions
with Micronaut
Álvaro Sánchez-Mariscal
@alvaro_sanchez
About me
— Coming from Madrid
!
— Developer since 2001 (Java / Spring stack).
— Former BEA Systems
⚰
and Sun Microsystems
— Founded Salenda in 2007. Left in 2013.
— Working @ OCI since 2015: Groovy, Grails & Micronaut!
— Speaker at conferences like Devoxx, GeeCON,
JavaLand, JavaZone, Codemotion and Spring IO.
! % & ' ( ) * + , -
@alvaro_sanchez
Introducing
@alvaro_sanchez
 Introducing Micronaut
The productivity of Spring Boot / Grails with a
compile-time, non-blocking performance.
— Designed from the ground up with microservices and
the cloud in mind ("Natively Cloud Native").
— Ultra-lightweight and Reactive (based on Netty)
— Integrated AOP and Compile-Time DI for Java, Groovy
and Kotlin.
@alvaro_sanchez
Hello, Galaxy!
interface HelloApi {
@Get("/hello") String hello();
}
@Controller("/")
class HelloServer implements HelloApi {
@Get("/hello")
public String hello() {
return "Hello, Galaxy!";
}
}
@Client("/") // Client Generated at Compile Time
interface HelloClient extends HelloApi {}
@alvaro_sanchez
Hello, Galaxy!
@MicronautTest
class ApplicationTest {
@Inject
HelloClient helloClient;
@Test
void testHello() {
Assertions.assertEquals("Hello, Galaxy!", helloClient.hello());
}
}
@alvaro_sanchez
Natively Cloud Native
— Service Discovery - Consul, Eureka, Route 53 and
Kubernetes.
— Configuration Sharing - Consul Supported and
Amazon ParameterStore planned.
— Client Side Load Balancing - Integrated or Netflix
Ribbon Supported
— Distributed tracing - Zipkin or Jaeger.
— Support for Serverless Computing; AWS Lambda,
@alvaro_sanchez
Ge!ing started
$ curl -s "https://get.sdkman.io" | bash
$ sdk install micronaut
$ mn create-function uppercase
| Generating Java project...
| Function created at /tmp/uppercase
@alvaro_sanchez
Ge!ing started: @FunctionBean
import io.micronaut.function.FunctionBean;
import java.util.function.Function;
@FunctionBean("isbn-validator")
public class IsbnValidatorFunction
implements Function<IsbnValidationRequest, IsbnValidationResponse> {
@Override
public IsbnValidationResponse apply(IsbnValidationRequest request) {
return new IsbnValidationResponse(); //do stuff
}
}
@alvaro_sanchez
Ge!ing started: @FunctionBean
— Use Java 8's java.util.function.*:
— Supplier<O>: no arguments, single result.
— Consumer<I>: single argument, no result.
— BiConsumer<I, J>: two arguments, no result.
— Function<I, O>: single argument, single result.
— Function<I, J, O>: two arguments, single result.
@alvaro_sanchez
Ge!ing started: @Factory
@Factory
public class WordFunctions {
@FunctionBean("uppercase")
public Function<String, String> uppercase() {
return String::toUpperCase;
}
@FunctionBean("lowercase")
public Function<String, String> lowercase() {
return String::toLowerCase;
}
}
@alvaro_sanchez
Ge!ing started: Groovy
//src/main/groovy/com/acme/HelloFunction.groovy
import groovy.transform.Field
import javax.inject.Inject
@Field @Inject HelloService helloService
String hello(String name) {
helloService.hello(name)
}
@alvaro_sanchez
Testing functions
— Micronaut can expose functions as local REST
endpoints.
— @FunctionClient can be leveraged in tests:
@FunctionClient
public interface IsbnValidatorClient {
@Named("isbn-validator")
@Retryable(attempts = "5", delay = "5s")
Single<IsbnValidationResponse> validate(@Body IsbnValidationRequest req);
}
@alvaro_sanchez
Invoking remote functions
— The same @FunctionClient can invoke remote
functions:
# src/main/resources/application.yml
aws:
lambda:
functions:
slack:
functionName: slack-message
region: eu-west-1
@alvaro_sanchez
Functions as CLI applications
— The build is configured to produce runnable JARs:
$ echo '{value: 3}' | java -jar build/libs/math-function-0.1-all.jar
— This allows functions written with Micronaut to be
deployed to platforms that process standard input/
output, such as OpenFaaS.
@alvaro_sanchez
GraalVM
— New Polyglot VM from Oracle.
— Runs JS, Java, Ruby, R etc.
— Ability to turn Java code into native images.
— Can run Micronaut applications and functions
blazingly fast!
@alvaro_sanchez
Demo
Q & A
Álvaro Sánchez-Mariscal
@alvaro_sanchez

Mais conteúdo relacionado

Mais procurados

sbt 0.10 for beginners?
sbt 0.10 for beginners?sbt 0.10 for beginners?
sbt 0.10 for beginners?
k4200
 
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter PilgrimJavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
HotPush with Ionic 2 and CodePush
HotPush with Ionic 2 and CodePushHotPush with Ionic 2 and CodePush
HotPush with Ionic 2 and CodePush
Evan Schultz
 

Mais procurados (20)

Apache Camel - FUSE community day London 2010 presentation
Apache Camel - FUSE community day London 2010 presentationApache Camel - FUSE community day London 2010 presentation
Apache Camel - FUSE community day London 2010 presentation
 
Developing, Testing and Scaling with Apache Camel - UberConf 2015
Developing, Testing and Scaling with Apache Camel - UberConf 2015Developing, Testing and Scaling with Apache Camel - UberConf 2015
Developing, Testing and Scaling with Apache Camel - UberConf 2015
 
sbt 0.10 for beginners?
sbt 0.10 for beginners?sbt 0.10 for beginners?
sbt 0.10 for beginners?
 
The JavaFX Ecosystem
The JavaFX EcosystemThe JavaFX Ecosystem
The JavaFX Ecosystem
 
EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3
EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3
EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3
 
Angular beans
Angular beansAngular beans
Angular beans
 
Micronaut For Single Page Apps
Micronaut For Single Page AppsMicronaut For Single Page Apps
Micronaut For Single Page Apps
 
Spring boot for buidling microservices
Spring boot for buidling microservicesSpring boot for buidling microservices
Spring boot for buidling microservices
 
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter PilgrimJavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
 
Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot Introduction
 
Workshop 22: React-Redux Middleware
Workshop 22: React-Redux MiddlewareWorkshop 22: React-Redux Middleware
Workshop 22: React-Redux Middleware
 
HotPush with Ionic 2 and CodePush
HotPush with Ionic 2 and CodePushHotPush with Ionic 2 and CodePush
HotPush with Ionic 2 and CodePush
 
Angular2 Development for Java developers
Angular2 Development for Java developersAngular2 Development for Java developers
Angular2 Development for Java developers
 
Getting started with ReactJS
Getting started with ReactJSGetting started with ReactJS
Getting started with ReactJS
 
Workshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte IIWorkshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte II
 
手把手教你如何串接 Log 到各種網路服務
手把手教你如何串接 Log 到各種網路服務手把手教你如何串接 Log 到各種網路服務
手把手教你如何串接 Log 到各種網路服務
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScript
 
Play Framework workshop: full stack java web app
Play Framework workshop: full stack java web appPlay Framework workshop: full stack java web app
Play Framework workshop: full stack java web app
 
Learn react-js
Learn react-jsLearn react-js
Learn react-js
 
JavaCro'14 - Unit testing in AngularJS – Slaven Tomac
JavaCro'14 - Unit testing in AngularJS – Slaven TomacJavaCro'14 - Unit testing in AngularJS – Slaven Tomac
JavaCro'14 - Unit testing in AngularJS – Slaven Tomac
 

Semelhante a Serverless functions with Micronaut

Quick Start to iOS Development
Quick Start to iOS DevelopmentQuick Start to iOS Development
Quick Start to iOS Development
Jussi Pohjolainen
 

Semelhante a Serverless functions with Micronaut (20)

React Basic and Advance || React Basic
React Basic and Advance   || React BasicReact Basic and Advance   || React Basic
React Basic and Advance || React Basic
 
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
 
Modular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJSModular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJS
 
Java Technology Define In Short Time
Java Technology Define In  Short TimeJava Technology Define In  Short Time
Java Technology Define In Short Time
 
B.Sc. III(VI Sem) Advance Java Unit2: Appet
B.Sc. III(VI Sem) Advance Java Unit2: AppetB.Sc. III(VI Sem) Advance Java Unit2: Appet
B.Sc. III(VI Sem) Advance Java Unit2: Appet
 
Quick Start to iOS Development
Quick Start to iOS DevelopmentQuick Start to iOS Development
Quick Start to iOS Development
 
A tour through Swift attributes
A tour through Swift attributesA tour through Swift attributes
A tour through Swift attributes
 
Java concurrency model - The Future Task
Java concurrency model - The Future TaskJava concurrency model - The Future Task
Java concurrency model - The Future Task
 
Refactoring JavaScript Applications
Refactoring JavaScript ApplicationsRefactoring JavaScript Applications
Refactoring JavaScript Applications
 
JSAnkara Swift v React Native
JSAnkara Swift v React NativeJSAnkara Swift v React Native
JSAnkara Swift v React Native
 
Micro Front-Ends
Micro Front-EndsMicro Front-Ends
Micro Front-Ends
 
Webpack Encore Symfony Live 2017 San Francisco
Webpack Encore Symfony Live 2017 San FranciscoWebpack Encore Symfony Live 2017 San Francisco
Webpack Encore Symfony Live 2017 San Francisco
 
Os Haase
Os HaaseOs Haase
Os Haase
 
Play Support in Cloud Foundry
Play Support in Cloud FoundryPlay Support in Cloud Foundry
Play Support in Cloud Foundry
 
Refactoring Large Web Applications with Backbone.js
Refactoring Large Web Applications with Backbone.jsRefactoring Large Web Applications with Backbone.js
Refactoring Large Web Applications with Backbone.js
 
Refactor Large applications with Backbone
Refactor Large applications with BackboneRefactor Large applications with Backbone
Refactor Large applications with Backbone
 
Refactor Large apps with Backbone
Refactor Large apps with BackboneRefactor Large apps with Backbone
Refactor Large apps with Backbone
 
What's new in java 9?
What's new in java 9?What's new in java 9?
What's new in java 9?
 
Griffon Presentation
Griffon PresentationGriffon Presentation
Griffon Presentation
 
Javazone 2019 - Mutants to the rescue: How effective are your unit tests?
Javazone 2019 - Mutants to the rescue: How effective are your unit tests?Javazone 2019 - Mutants to the rescue: How effective are your unit tests?
Javazone 2019 - Mutants to the rescue: How effective are your unit tests?
 

Mais de Alvaro Sanchez-Mariscal

Stateless authentication with OAuth 2 and JWT - JavaZone 2015
Stateless authentication with OAuth 2 and JWT - JavaZone 2015Stateless authentication with OAuth 2 and JWT - JavaZone 2015
Stateless authentication with OAuth 2 and JWT - JavaZone 2015
Alvaro Sanchez-Mariscal
 

Mais de Alvaro Sanchez-Mariscal (20)

Asynchronous and event-driven Grails applications
Asynchronous and event-driven Grails applicationsAsynchronous and event-driven Grails applications
Asynchronous and event-driven Grails applications
 
Practical Spring Cloud
Practical Spring CloudPractical Spring Cloud
Practical Spring Cloud
 
Creating applications with Grails, Angular JS and Spring Security - G3 Summit...
Creating applications with Grails, Angular JS and Spring Security - G3 Summit...Creating applications with Grails, Angular JS and Spring Security - G3 Summit...
Creating applications with Grails, Angular JS and Spring Security - G3 Summit...
 
Mastering Grails 3 Plugins - G3 Summit 2016
Mastering Grails 3 Plugins - G3 Summit 2016Mastering Grails 3 Plugins - G3 Summit 2016
Mastering Grails 3 Plugins - G3 Summit 2016
 
Desarrollo de aplicaciones con Grails 3, Angular JS y Spring Security
Desarrollo de aplicaciones con Grails 3, Angular JS y Spring SecurityDesarrollo de aplicaciones con Grails 3, Angular JS y Spring Security
Desarrollo de aplicaciones con Grails 3, Angular JS y Spring Security
 
Creating applications with Grails, Angular JS and Spring Security - GR8Conf U...
Creating applications with Grails, Angular JS and Spring Security - GR8Conf U...Creating applications with Grails, Angular JS and Spring Security - GR8Conf U...
Creating applications with Grails, Angular JS and Spring Security - GR8Conf U...
 
Mastering Grails 3 Plugins - GR8Conf US 2016
Mastering Grails 3 Plugins - GR8Conf US 2016Mastering Grails 3 Plugins - GR8Conf US 2016
Mastering Grails 3 Plugins - GR8Conf US 2016
 
Mastering Grails 3 Plugins - GR8Conf EU 2016
Mastering Grails 3 Plugins - GR8Conf EU 2016Mastering Grails 3 Plugins - GR8Conf EU 2016
Mastering Grails 3 Plugins - GR8Conf EU 2016
 
Creating applications with Grails, Angular JS and Spring Security - GR8Conf E...
Creating applications with Grails, Angular JS and Spring Security - GR8Conf E...Creating applications with Grails, Angular JS and Spring Security - GR8Conf E...
Creating applications with Grails, Angular JS and Spring Security - GR8Conf E...
 
Mastering Grails 3 Plugins - Greach 2016
Mastering Grails 3 Plugins - Greach 2016Mastering Grails 3 Plugins - Greach 2016
Mastering Grails 3 Plugins - Greach 2016
 
Creating applications with Grails, Angular JS and Spring Security
Creating applications with Grails, Angular JS and Spring SecurityCreating applications with Grails, Angular JS and Spring Security
Creating applications with Grails, Angular JS and Spring Security
 
Efficient HTTP applications on the JVM with Ratpack - Voxxed Days Berlin 2016
Efficient HTTP applications on the JVM with Ratpack - Voxxed Days Berlin 2016Efficient HTTP applications on the JVM with Ratpack - Voxxed Days Berlin 2016
Efficient HTTP applications on the JVM with Ratpack - Voxxed Days Berlin 2016
 
Efficient HTTP applications on the JVM with Ratpack - JDD 2015
Efficient HTTP applications on the JVM with Ratpack - JDD 2015Efficient HTTP applications on the JVM with Ratpack - JDD 2015
Efficient HTTP applications on the JVM with Ratpack - JDD 2015
 
Stateless authentication with OAuth 2 and JWT - JavaZone 2015
Stateless authentication with OAuth 2 and JWT - JavaZone 2015Stateless authentication with OAuth 2 and JWT - JavaZone 2015
Stateless authentication with OAuth 2 and JWT - JavaZone 2015
 
Stateless authentication for microservices - GR8Conf 2015
Stateless authentication for microservices - GR8Conf 2015Stateless authentication for microservices - GR8Conf 2015
Stateless authentication for microservices - GR8Conf 2015
 
Ratpack 101 - GR8Conf 2015
Ratpack 101 - GR8Conf 2015Ratpack 101 - GR8Conf 2015
Ratpack 101 - GR8Conf 2015
 
Ratpack 101 - GeeCON 2015
Ratpack 101 - GeeCON 2015Ratpack 101 - GeeCON 2015
Ratpack 101 - GeeCON 2015
 
Stateless authentication for microservices - Spring I/O 2015
Stateless authentication for microservices  - Spring I/O 2015Stateless authentication for microservices  - Spring I/O 2015
Stateless authentication for microservices - Spring I/O 2015
 
Stateless authentication for microservices - Greach 2015
Stateless authentication for microservices - Greach 2015Stateless authentication for microservices - Greach 2015
Stateless authentication for microservices - Greach 2015
 
Stateless authentication for microservices applications - JavaLand 2015
Stateless authentication for microservices applications -  JavaLand 2015Stateless authentication for microservices applications -  JavaLand 2015
Stateless authentication for microservices applications - JavaLand 2015
 

Último

%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Último (20)

WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 

Serverless functions with Micronaut

  • 1. Serverless functions with Micronaut Álvaro Sánchez-Mariscal @alvaro_sanchez
  • 2. About me — Coming from Madrid ! — Developer since 2001 (Java / Spring stack). — Former BEA Systems ⚰ and Sun Microsystems — Founded Salenda in 2007. Left in 2013. — Working @ OCI since 2015: Groovy, Grails & Micronaut! — Speaker at conferences like Devoxx, GeeCON, JavaLand, JavaZone, Codemotion and Spring IO. ! % & ' ( ) * + , - @alvaro_sanchez
  • 5.  Introducing Micronaut The productivity of Spring Boot / Grails with a compile-time, non-blocking performance. — Designed from the ground up with microservices and the cloud in mind ("Natively Cloud Native"). — Ultra-lightweight and Reactive (based on Netty) — Integrated AOP and Compile-Time DI for Java, Groovy and Kotlin. @alvaro_sanchez
  • 6. Hello, Galaxy! interface HelloApi { @Get("/hello") String hello(); } @Controller("/") class HelloServer implements HelloApi { @Get("/hello") public String hello() { return "Hello, Galaxy!"; } } @Client("/") // Client Generated at Compile Time interface HelloClient extends HelloApi {} @alvaro_sanchez
  • 7. Hello, Galaxy! @MicronautTest class ApplicationTest { @Inject HelloClient helloClient; @Test void testHello() { Assertions.assertEquals("Hello, Galaxy!", helloClient.hello()); } } @alvaro_sanchez
  • 8. Natively Cloud Native — Service Discovery - Consul, Eureka, Route 53 and Kubernetes. — Configuration Sharing - Consul Supported and Amazon ParameterStore planned. — Client Side Load Balancing - Integrated or Netflix Ribbon Supported — Distributed tracing - Zipkin or Jaeger. — Support for Serverless Computing; AWS Lambda, @alvaro_sanchez
  • 9. Ge!ing started $ curl -s "https://get.sdkman.io" | bash $ sdk install micronaut $ mn create-function uppercase | Generating Java project... | Function created at /tmp/uppercase @alvaro_sanchez
  • 10. Ge!ing started: @FunctionBean import io.micronaut.function.FunctionBean; import java.util.function.Function; @FunctionBean("isbn-validator") public class IsbnValidatorFunction implements Function<IsbnValidationRequest, IsbnValidationResponse> { @Override public IsbnValidationResponse apply(IsbnValidationRequest request) { return new IsbnValidationResponse(); //do stuff } } @alvaro_sanchez
  • 11. Ge!ing started: @FunctionBean — Use Java 8's java.util.function.*: — Supplier<O>: no arguments, single result. — Consumer<I>: single argument, no result. — BiConsumer<I, J>: two arguments, no result. — Function<I, O>: single argument, single result. — Function<I, J, O>: two arguments, single result. @alvaro_sanchez
  • 12. Ge!ing started: @Factory @Factory public class WordFunctions { @FunctionBean("uppercase") public Function<String, String> uppercase() { return String::toUpperCase; } @FunctionBean("lowercase") public Function<String, String> lowercase() { return String::toLowerCase; } } @alvaro_sanchez
  • 13. Ge!ing started: Groovy //src/main/groovy/com/acme/HelloFunction.groovy import groovy.transform.Field import javax.inject.Inject @Field @Inject HelloService helloService String hello(String name) { helloService.hello(name) } @alvaro_sanchez
  • 14. Testing functions — Micronaut can expose functions as local REST endpoints. — @FunctionClient can be leveraged in tests: @FunctionClient public interface IsbnValidatorClient { @Named("isbn-validator") @Retryable(attempts = "5", delay = "5s") Single<IsbnValidationResponse> validate(@Body IsbnValidationRequest req); } @alvaro_sanchez
  • 15. Invoking remote functions — The same @FunctionClient can invoke remote functions: # src/main/resources/application.yml aws: lambda: functions: slack: functionName: slack-message region: eu-west-1 @alvaro_sanchez
  • 16. Functions as CLI applications — The build is configured to produce runnable JARs: $ echo '{value: 3}' | java -jar build/libs/math-function-0.1-all.jar — This allows functions written with Micronaut to be deployed to platforms that process standard input/ output, such as OpenFaaS. @alvaro_sanchez
  • 17. GraalVM — New Polyglot VM from Oracle. — Runs JS, Java, Ruby, R etc. — Ability to turn Java code into native images. — Can run Micronaut applications and functions blazingly fast! @alvaro_sanchez
  • 18. Demo
  • 19.
  • 20. Q & A Álvaro Sánchez-Mariscal @alvaro_sanchez