apis rest
DESCRIPTION
RESTTRANSCRIPT
![Page 1: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/1.jpg)
A P I R E S T W I T H J AVAA N O P I N I O N A T E D A P P R O A C H
Lima, Perú. Diciembre 2015
![Page 2: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/2.jpg)
– B E C A U S E A N A
'Como construir APIs REST para sistemas distribuidos con alta escalabilidad y resilencia '
![Page 3: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/3.jpg)
D I S C L A I M E R
• This talk and its contents are based in my own experience.
• I’m not trying to say all the following IS the way to do the right thing. Just my opinion. :)
• All I want is to share my experience with the community.
• This talk is huge. Hope I can finish on time.
![Page 4: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/4.jpg)
M O T I VAT I O N
• Functional requirements is THE challenge.
• API Documentation is always a PITA, keep in sync with the maintenance, new features, fixes, etc.
• Build any API (REST, SOAP, RPC) is hard.
• Development tools choice (programming language, libraries, frameworks, runtime, etc).
• Non functional requirements, quality attributes.
![Page 5: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/5.jpg)
A P I C O N T R A C T
![Page 6: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/6.jpg)
A P I C O N T R A C T
• Always is over there. Implicit/Explicit
• You should have one.
• You should know it.
• No matter if you build it or you consume the API.
• You should give it so much love.
• Learn to love it.
![Page 7: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/7.jpg)
A P I C O N T R A C T A P P R O A C H E S
• Contract last
• Code driven contract
• Contract first
• Upfront design
![Page 8: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/8.jpg)
C O N T R A C T L A S T
• Sadly is the commonest.
• Server-side developers dictate the contract.
• Most of the time with only one perspective.
• Implementator perspective VS consumer perpective
• Flaky. If missing test cases. Fragile.
• The documentation is done at the end.
• Bottleneck.
![Page 9: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/9.jpg)
C O N T R A C T F I R S T
• Upfront design API
• Consumer perspective design
• Reusability
• Versioning
• Performance
![Page 10: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/10.jpg)
The contract as corner stone for REST APIs
![Page 11: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/11.jpg)
H O W T O B U I L D T H E C O N T R A C T ?
![Page 12: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/12.jpg)
T O O L S
![Page 13: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/13.jpg)
![Page 14: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/14.jpg)
![Page 15: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/15.jpg)
![Page 16: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/16.jpg)
S O M A N Y O T H E R S : )
![Page 17: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/17.jpg)
R A M L , M Y FAV O R I T E
• YAML dialect + JSON schema #ftw (types)
• Readable for humans.
• Can be procesable by machines.
• Design clear, correct, precise & consistent APIs.
• No vendor lock-in.
![Page 18: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/18.jpg)
![Page 19: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/19.jpg)
![Page 20: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/20.jpg)
![Page 21: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/21.jpg)
![Page 22: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/22.jpg)
J S O N - S C H E M A S A M P L E
![Page 23: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/23.jpg)
![Page 24: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/24.jpg)
![Page 25: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/25.jpg)
D E S I G N & B U I L D
![Page 26: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/26.jpg)
![Page 27: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/27.jpg)
![Page 28: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/28.jpg)
![Page 29: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/29.jpg)
![Page 30: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/30.jpg)
R A M L + R A M L - M O C K U P
We can deliver an API in days or hours
![Page 31: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/31.jpg)
R A M L & C O D E G E N E R AT I O N
• Server side
• JAX-RS
• Client
• Square Retrofit
• Documentation
• HTML
![Page 32: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/32.jpg)
R A M L 2 C O D E
• OpenSource project from Grupo Expansión
• Generates Plain Old Java/Groovy Objects
• Generates JAX-RS interfases
• Generates an API client with Retrofit
• Can run in Android also in any JVM application.
![Page 33: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/33.jpg)
![Page 34: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/34.jpg)
![Page 35: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/35.jpg)
N I C E , N O W I K N O W H O W T O C R E AT E A C O N T R A C T. W H AT ’ S N E X T ?
![Page 36: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/36.jpg)
P R O G R A M M I N G M O D E LArchitecture
![Page 37: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/37.jpg)
S O A + E D A
![Page 38: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/38.jpg)
S E R V I C E S
• Build, deploy, and monitor any kind of services in agile, efficient way with open standards.
• Deployment on-premise, in the cloud, mix of both.
• Deploy services independently from each other.
• Decoupled & scale linearly across commodity hardware.
![Page 39: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/39.jpg)
W A I T, A B U Z Z W O R D I S C O M I N G …
![Page 40: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/40.jpg)
M I C R O S E R V I C E S A R C H I T E C T U R E
• Service Contracts
• RAML
• Exposing new & existing services
• Enterprise Integration Patterns (integration, routing, transformation)
• Discovery of services
• Service Registry
![Page 41: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/41.jpg)
M I C R O S E R V I C E S A R C H I T E C T U R E
• Coordination across services
• Event Bus, (smart service, dump pipe)
• Managing complex deployments and their scalability
• Build Tool, CI, DevOps (Chef, Puppet), Linux Containers, Cloud, monitoring
• Visibility and correlation across services
• Event correlation, ElasticSearch, Logstash, Kibana.
![Page 42: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/42.jpg)
S O U N D S N I C E , B U T…
![Page 43: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/43.jpg)
![Page 44: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/44.jpg)
I M P L E M E N TAT I O N D E TA I L S
![Page 45: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/45.jpg)
S P R I N G B O O T I S A W E S O M E
![Page 46: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/46.jpg)
– S P R I N G B O O T R E F E R E N C E D O C U M E N TAT I O N
“Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that
you can “just run”. We take an opinionated view of the Spring platform and third-party libraries so you
can get started with minimum fuss. Most Spring Boot applications need very little Spring
configuration.”
![Page 47: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/47.jpg)
S P R I N G B O O T
• Embedded Servlet container
• Tomcat
• Jetty
• Undertow
• Executable jar file. Key feature for microservices!
• Monitoring capabilities thanks to actuator
• HealthChecks
• Metrics (Dropwizard aka Coda Hale Metrics)
• Jolokia
![Page 48: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/48.jpg)
S P R I N G B O O T & J A X - R S
• Jersey 2.x support out of the box
• Just use the Jersey Starter
• spring-boot-starter-jersey
• raml2code generates JAX-RS artifacts, remember?
![Page 49: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/49.jpg)
S P R I N G C L O U D
• Distributed/versioned configuration
• Service registration and discovery
• Routing
• Service-to-service calls
• Load balancing
• Circuit Breakers
• Global locks
• Leadership election and cluster state
• Distributed messaging
![Page 50: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/50.jpg)
N E T F L I X O S S
• Netflix is released tons of good stuff.
• Reactive Extensions for Java
• Hystrix (Circuit breaker)
• Eureka (Service registry)
• Archaius (Configuration management)
• Zuul (Dynamic routing, monitoring, resilience, security)
• And many more…
![Page 51: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/51.jpg)
S P R I N G B O O T L O V E S N E T F L I X O S S
![Page 52: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/52.jpg)
S P R I N G B O O T & S P R I N G C L O U D F O R I M PAT I E N T D E V E L O P E R S
![Page 53: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/53.jpg)
![Page 54: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/54.jpg)
A C K N O W L E D G M E N T S
• To all the platform team at Grupo Expansión
• Alvaro Cabrera (@pateketrueke)
• Anallely Olivares (@tsunllly)
• Angel Pimentel (@blzb)
• Eduardo Diaz (@iamedu)
• Tomás Salazar (@atomsfat)
• Domingo Suarez Torres (@domix)
![Page 55: Apis Rest](https://reader031.vdocuments.net/reader031/viewer/2022020417/5695cef61a28ab9b028bfec9/html5/thumbnails/55.jpg)
C O N TA C T O
• http://twitter.com/domix
• http://domingosuarez.com
• http://github.com/domix