SlideShare a Scribd company logo
SPRINGONE2GX
WASHINGTON, DC
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attributio n-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Ratpack Web Framework
By Dan Woods
@danveloper
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
About Me
• Member of the Ratpack Web core team
• Author of “Learning Ratpack”, O’Reilly
• http://shop.oreilly.com/product/0636920037545.do
• Senior Engineer, The Groundwork
• https://github.com/danveloper
2
1st Four Chapters Available Today!
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Ratpack Team on Twitter
3
Follow this crew!
• @ldaley
• @varzof
• @rus_hart
• @beckje01
• @marcinerdmann
• @zedar185
• @Lspacewalker
• @johnrengelman
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Brief History of Ratpack
• Ratpack started out as a Groovy DSL implementation example (2010)
• Evolved steadily into a JVM Sinatra clone (2010-2011)
• Dumped Sinatra legacy and started focusing on NIO/performance (2012)
• Under steady development in its modern form for 3 full years!
4
GroovyDSLImplementation
JVMSinatraClone
Drop“Sinatra”,NIO/Perf
DropsServletsforVert.x
CorerewritteninJava
Movestoorg.ratpackpackages
ExecutionModelIntroduced
Bootstraping,Config
Registryisintroduced
MovefromVert.xtoNetty
Stable,ProductionReady–1.0
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Overview of Ratpack
• Ratpack is now at version 1.0.0
• Production-ready, API-stable
• Can safely adopt without fear of breaking API changes
• Great option for building microservices
• Can also be integrated into legacy apps through its robust test fixtures
5
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Overview of Ratpack
• A high performance web framework
• Built on a non-blocking network stack
• Provides low-level constructs for working with async APIs
• Core is written in Java (requires Java 8)
• Integrated support for building Groovy-based applications
• Emphasis on developer productivity
• As few opinions as possible
• Fast, self-contained, light-weight deployables
6
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Simplest Hello World Example
• Just a few lines of Groovy code required!
7
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Simplest Hello World Example
• Totally Tweetable! https://twitter.com/danveloper/status/608298173208100864
8
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Java Hello World Example
• Still, not very much needed at all…
9
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Overview of Ratpack
• Support for HTML templates with Groovy and Handlebars
10
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Overview of Ratpack
• Great for microservices!
• First-class support for language agnostic transport
11
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Overview of Ratpack
• Non-blocking HTTP client
12
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Overview of Ratpack
• Fault tolerance for building distributed systems
13
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Overview of Ratpack
• Support for metric reporting with Dropwizard Metrics
14
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Overview of Ratpack
• Comprehensive configuration model
15
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Overview of Ratpack
• Support for persistent sessions
16
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Overview of Ratpack
• Robust security with Pac4j
17
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Overview of Ratpack
• Out of the box SSL support
18
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Performance
• Like most frameworks, Ratpack is CPU-bound (the more CPUs, the better)
• Unlike most frameworks, Ratpack efficiently processes on each CPU
19
https://gist.github.com/danveloper/db888be3519966976368
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Execution Model
• The execution model in Ratpack is borne from the fact that the JVM has no
inherent support for Continuations
• Asynchronous programming is difficult
• Async processing introduces non-determinism
• Web applications require deterministic processing
20
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Execution Model
• Ratpack wants to make Async processing and programming a reliable and
usable model for the JVM
• By fitting into the execution model, applications garner confidence from a
deterministic processing flow
21
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
TPR/TPC Processing Model
• How most JVM web frameworks work
22
Internet Web App
new Thread().start()
Blocking
Processing
Process and wait
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
TPR/TPC Processing Model
• In the thread-per-request (or thread-per-connection) model, you are limited by
the amount of threads that you can create
• Bringing the data from a request-taking thread and placing it into a processing
thread incurs a context switch
• The processing thread is where all your work is done, and is established until
you respond
• This is not performant at all, but it is an easy model to program in, and that’s
why people use it
23
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Ratpack Processing Model
• How Ratpack works (4 CPU example)
24
Internet Event Loop
Event Loop
Event Loop
Event Loop
Handler
Waiting for something?
(db call, call to remote)
Return thread to
request-taking pool
while we wait
Respond
One thread per CPU core
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Ratpack Processing Model
• Only establishes a single thread per CPU core
• Processing doesn’t block the thread (if it needs to, then we can schedule it to
the blocking thread pool)
• While we wait for async responses to be fulfilled, the thread is able to process
other requests
• When we get the async response, processing continues on the same thread
• No context switching in computation handlers, async processing responds when
its work is done
25
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Problems with Async Programming
• Callbacks are obnoxious to work with
• No good way to detect when waiting for async responses
• Represents a temporal disconnect from the processing flow
• Most async web frameworks start a timer when a request comes in, and if you
don’t respond by the time that’s over, then it assumes you’re not going to
26
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Problems with Async Programming
27
Callback
HELL
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Problems with Async Programming
28
With Ratpack Promises, you
get guaranteed execution
order without the need
scoped callbacks.
<1> - definitely happens 1st
<2> - definitely happens 2nd
<3> - definitely happens 3rd
<4> - definitely happens 4th
<5> - definitely happens 5th
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Problems with Async Programming
29
In other async web
frameworks:
The clock is ticking for you
to get that response out
before the framework
shuts you down
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Problems with Async Programming
30
Execution
|__stream
|__marker
|__flatMap(..)
|__findByUsername
|__stream
|__marker
|__flatMap(..)
|__loadProfile
|__stream
|__marker
|__flatMap(..)
|__loadFriends
|__stream
|__marker
|__flatMap(..)
|__loadFriendPhotos
|__stream
|__marker
|__render(..)
|__then(..)
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Execution Model
• The overall execution is a parallel to the construct of a continuation
• Each of the calls to a Promise represent a frame in the execution
• Each of the Promise types represents a new processing stream in the
execution
• While async processing is taking place (ie. Promise is not fulfilled), the
execution is suspended
• When the execution is suspended, the processing thread is given back to the
event loop to continue processing requests
• When an async call returns, the execution is resumed
31
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Execution Model
• Most importantly, we know that when we hit the marker on a processing stream
that the stream is done computing
• The processing streams are supervised by Ratpack to know that a request is
still processing
• If your code doesn’t respond to a request, we don’t need to wait until the
request times out to inform the client
• If all the streams are done computing but no response has been sent, we are
aware of that and can send an appropriate error back (no response sent) to the
client
32
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Execution Model
• Ratpack’s execution model gives you much higher confidence in working with
async programming
• The Promise type makes async programming easier
• Deterministic async processing gives added benefits for concurrency
• You have better confidence when programming to async APIs with Ratpack
• Fun fact: any API can be made asynchronous in Ratpack
33
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Blocking Done Right
• To make use of most 3rd party Java libraries, blocking will need to take place at
some point
• A prime example here is using JDBC
• Since you can’t block on the request-taking thread, you will need to do blocking
on a separate thread
• Any non-trivial application will need to do blocking at some point…
• Ratpack provides easy fixtures for Promise types to be scheduled for
computation or blocking
34
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Blocking Done Right
35
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Dependency Injection
• Ratpack is not tied to any particular dependency injection framework
• DI is an abstract concept in Ratpack, components are registered via a Registry
• Ratpack apps can be built entirely without any DI
• Framework modularity is accomplished via Guice
• 1st class support for Guice and Spring Boot
36
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Registry
• There are multiple registries in Ratpack
• Provide components at different layers of the framework
37
Server Registry
User Registry
Context Registry
Request Registry
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Registry
• Components can be bound to the user registry at start time
38
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Registry
• Registries can be built and cascaded at request time, and according to request
attributes
39
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Registry
• Registries can be backed by Guice…
40
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Registry
• … or by Spring Boot…
41
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Registry
• … or both …
42
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Dependency Injection
• In Groovy, dependency injection can be accomplished by simply specifying the
type as a closure argument
43
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Dependency Injection
• Taking a completely unopinionated approach to dependency injection allows
implementations to be flexible
• Can support nearly every component-providing backend
• Gives you the ability to leverage the best parts of all available ecosystems
• New Ratpack apps can readily fit into legacy infrastructures that do have
opinions about this stuff
44
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Build System Support
• Ratpack is just a set of libraries, so any Java build system can build your project
• Advanced integration with Gradle is provided through the ratpack-gradle plugin
• Using Gradle is the easiest way to get started
• Gradle plugin provides version-proper dependency resolution, so you don’t
need to update versions as you upgrade your project
45
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Build System Support
• Just a set of libraries…
46
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Build System Support
• Advanced integration with Gradle…
47
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Build System Support
• Ratpack apps can be easily packaged for deployment with Gradle
• Multiple options: fat jar, tarball, zip file
• Gradle plugin applies the application plugin, so distributions and dependencies
can easily be built and shipped with os start scripts
• Fat JAR building is accomplished via the ShadowJar plugin
48
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Developer Productivity
• Development time hot reloading is provided via Gradle’s “continuous build”
mode
• Standalone Ratpack Groovy scripts are able to be reloaded when the
development serverConfig option is true
49
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
The Handler Chain
• Denotes the edge of your application
• Requests flow through the chain until reaching a handler than can provide a
response
• Two types of handlers: request flow and terminal
• Request Flow handlers manage the direction the request takes through the
chain
• Terminal handlers process a request and respond to it
50
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
The Handler Chain
• Request flow handler
51
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
The Handler Chain
• Terminal handler
52
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
The Handler Chain
• Chain API provides semantic methods to bind a handler to an HTTP verb and
optionally a path
• get(..), post(..), put(..), patch(..), delete(..) methods will bind accordingly
• Can also bind a handler that will be called for every incoming request with the
all(..) and path(..) chain methods
53
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Live Coding Demo Time
54
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Questions?
55
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Join the Community
56
http://slack-signup.ratpack.io/

More Related Content

PDF
Ratpack Web Framework
PDF
Future of Grails
PDF
Groovy in the Cloud
PDF
Ratpack Web Framework
PDF
Intro to Ratpack (CDJDN 2015-01-22)
PDF
High Performance Microservices with Ratpack and Spring Boot
PDF
Migrating from Grails 2 to Grails 3
PDF
Grails 3.0 Preview
Ratpack Web Framework
Future of Grails
Groovy in the Cloud
Ratpack Web Framework
Intro to Ratpack (CDJDN 2015-01-22)
High Performance Microservices with Ratpack and Spring Boot
Migrating from Grails 2 to Grails 3
Grails 3.0 Preview

What's hot (20)

PDF
Full Steam Ahead, R2DBC!
PPT
Ratpack - Classy and Compact Groovy Web Apps
PDF
What’s new in grails framework 5?
PDF
Spring Boot on Amazon Web Services with Spring Cloud AWS
PDF
Enabling Cloud Native Buildpacks for Windows Containers
PPTX
Bootiful Reactive Testing - Mario Gray
PDF
Building Distributed Systems with Netflix OSS and Spring Cloud
PPTX
Building with Gradle
PDF
Maven beyond hello_world
PDF
Introduction to gradle
PDF
Devoxx : being productive with JHipster
PDF
Spring GraphQL
PDF
Ingress? That’s So 2020! Introducing the Kubernetes Gateway API
PDF
OpenShift for Java EE Developers
PDF
Drone presentation
PDF
Graalvm with Groovy and Kotlin - Madrid GUG 2019
PDF
Grails 4: Upgrade your Game!
PPTX
Dockerize it all
PDF
Developer Experience Cloud Native - Become Efficient and Achieve Parity
PDF
Modularizing your Grails Application with Private Plugins - SpringOne 2GX 2012
Full Steam Ahead, R2DBC!
Ratpack - Classy and Compact Groovy Web Apps
What’s new in grails framework 5?
Spring Boot on Amazon Web Services with Spring Cloud AWS
Enabling Cloud Native Buildpacks for Windows Containers
Bootiful Reactive Testing - Mario Gray
Building Distributed Systems with Netflix OSS and Spring Cloud
Building with Gradle
Maven beyond hello_world
Introduction to gradle
Devoxx : being productive with JHipster
Spring GraphQL
Ingress? That’s So 2020! Introducing the Kubernetes Gateway API
OpenShift for Java EE Developers
Drone presentation
Graalvm with Groovy and Kotlin - Madrid GUG 2019
Grails 4: Upgrade your Game!
Dockerize it all
Developer Experience Cloud Native - Become Efficient and Achieve Parity
Modularizing your Grails Application with Private Plugins - SpringOne 2GX 2012
Ad

Viewers also liked (20)

PPTX
leonardo monsalve
PDF
Content marketing that converts - Istanbul
PPTX
Collaboration friday
PPTX
Historia insp manuel antonio leal chacon
PPT
Wingss power point
PPTX
Collaboration friday
PDF
rhythm workshop
PDF
Grafico diario del dax perfomance index para el 11 02-2013
PPT
부용
PPTX
Impacto de las tics en la educaciòn
PDF
Brexit Webinar Series 3
PPTX
基隆交點Vol.5 - 王珈琳 - 陪伴,一段服務的時間
PDF
Auktuálne otázky zodpovednosti za porušovanie práv duševného vlastníctva online
PDF
Getting Open Data Used
DOCX
1 4 vamos a jugar
PDF
Women On Top: Celebrating Women in Business
PDF
5 Reasons Why Your Headlines Are On Life Support
PDF
Kerry Karl | Debunking Myths: GLUTEN
PPTX
Nuevas tecnologías de
PDF
Polyglot Gradle with Node.js and Play
leonardo monsalve
Content marketing that converts - Istanbul
Collaboration friday
Historia insp manuel antonio leal chacon
Wingss power point
Collaboration friday
rhythm workshop
Grafico diario del dax perfomance index para el 11 02-2013
부용
Impacto de las tics en la educaciòn
Brexit Webinar Series 3
基隆交點Vol.5 - 王珈琳 - 陪伴,一段服務的時間
Auktuálne otázky zodpovednosti za porušovanie práv duševného vlastníctva online
Getting Open Data Used
1 4 vamos a jugar
Women On Top: Celebrating Women in Business
5 Reasons Why Your Headlines Are On Life Support
Kerry Karl | Debunking Myths: GLUTEN
Nuevas tecnologías de
Polyglot Gradle with Node.js and Play
Ad

Similar to Ratpack - SpringOne2GX 2015 (20)

PDF
JDD2015: In English Efficient HTTP applications on the JVM with Ratpack - Álv...
PDF
Ratpack 101 - GeeCON 2015
PDF
Efficient HTTP applications on the JVM with Ratpack - JDD 2015
PDF
Ratpack the story so far
PPTX
Ratpack and Grails 3 (and Spring Boot) SpringOne 2GX 2014
PDF
Ratpack 101 - GR8Conf 2015
PDF
Efficient HTTP applications on the JVM with Ratpack - Voxxed Days Berlin 2016
PDF
Ratpack for Real
PDF
Reactive All the Way Down the Stack
PDF
Intro To Reactive Programming
PDF
Intro to Reactive Programming
PPTX
Building Web Apps in Ratpack
PPTX
SpringOne2GX 2014 Splunk Presentation
PPTX
What's new in Spring Boot 2.0
PDF
There's more to Ratpack than non-blocking
PDF
In the workshop with GCP, Home Depot & Cloud Foundry
PDF
PDF
Java Network Programming Third Edition 3rd Edition Elliotte Rusty Harold
PDF
OSCON 2014 - The Epic Battle: Scala at PayPal
PDF
Data Migration at Scale with RabbitMQ and Spring Integration
JDD2015: In English Efficient HTTP applications on the JVM with Ratpack - Álv...
Ratpack 101 - GeeCON 2015
Efficient HTTP applications on the JVM with Ratpack - JDD 2015
Ratpack the story so far
Ratpack and Grails 3 (and Spring Boot) SpringOne 2GX 2014
Ratpack 101 - GR8Conf 2015
Efficient HTTP applications on the JVM with Ratpack - Voxxed Days Berlin 2016
Ratpack for Real
Reactive All the Way Down the Stack
Intro To Reactive Programming
Intro to Reactive Programming
Building Web Apps in Ratpack
SpringOne2GX 2014 Splunk Presentation
What's new in Spring Boot 2.0
There's more to Ratpack than non-blocking
In the workshop with GCP, Home Depot & Cloud Foundry
Java Network Programming Third Edition 3rd Edition Elliotte Rusty Harold
OSCON 2014 - The Epic Battle: Scala at PayPal
Data Migration at Scale with RabbitMQ and Spring Integration

More from Daniel Woods (8)

PPTX
Continuous Delivery with Spinnaker and OpenStack
PPTX
Microservices: The Right Way
PDF
Facilitating Continuous Delivery at Scale
PDF
Continuous Delivery with NetflixOSS
PDF
Server-Side JavaScript with Nashorn
PPTX
Groovy for System Administrators
PPTX
Message Driven Architecture in Grails
PDF
Gainesville Web Developer Group, Sept 2012
Continuous Delivery with Spinnaker and OpenStack
Microservices: The Right Way
Facilitating Continuous Delivery at Scale
Continuous Delivery with NetflixOSS
Server-Side JavaScript with Nashorn
Groovy for System Administrators
Message Driven Architecture in Grails
Gainesville Web Developer Group, Sept 2012

Recently uploaded (20)

PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
Getting Started with Data Integration: FME Form 101
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Mushroom cultivation and it's methods.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
SOPHOS-XG Firewall Administrator PPT.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Empathic Computing: Creating Shared Understanding
Getting Started with Data Integration: FME Form 101
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Mushroom cultivation and it's methods.pdf
Programs and apps: productivity, graphics, security and other tools
NewMind AI Weekly Chronicles - August'25-Week II
OMC Textile Division Presentation 2021.pptx
Heart disease approach using modified random forest and particle swarm optimi...
Advanced methodologies resolving dimensionality complications for autism neur...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Spectral efficient network and resource selection model in 5G networks
Unlocking AI with Model Context Protocol (MCP)
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Building Integrated photovoltaic BIPV_UPV.pdf
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
cloud_computing_Infrastucture_as_cloud_p
Univ-Connecticut-ChatGPT-Presentaion.pdf

Ratpack - SpringOne2GX 2015

  • 1. SPRINGONE2GX WASHINGTON, DC Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attributio n-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Ratpack Web Framework By Dan Woods @danveloper
  • 2. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ About Me • Member of the Ratpack Web core team • Author of “Learning Ratpack”, O’Reilly • http://shop.oreilly.com/product/0636920037545.do • Senior Engineer, The Groundwork • https://github.com/danveloper 2 1st Four Chapters Available Today!
  • 3. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Ratpack Team on Twitter 3 Follow this crew! • @ldaley • @varzof • @rus_hart • @beckje01 • @marcinerdmann • @zedar185 • @Lspacewalker • @johnrengelman
  • 4. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Brief History of Ratpack • Ratpack started out as a Groovy DSL implementation example (2010) • Evolved steadily into a JVM Sinatra clone (2010-2011) • Dumped Sinatra legacy and started focusing on NIO/performance (2012) • Under steady development in its modern form for 3 full years! 4 GroovyDSLImplementation JVMSinatraClone Drop“Sinatra”,NIO/Perf DropsServletsforVert.x CorerewritteninJava Movestoorg.ratpackpackages ExecutionModelIntroduced Bootstraping,Config Registryisintroduced MovefromVert.xtoNetty Stable,ProductionReady–1.0
  • 5. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Overview of Ratpack • Ratpack is now at version 1.0.0 • Production-ready, API-stable • Can safely adopt without fear of breaking API changes • Great option for building microservices • Can also be integrated into legacy apps through its robust test fixtures 5
  • 6. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Overview of Ratpack • A high performance web framework • Built on a non-blocking network stack • Provides low-level constructs for working with async APIs • Core is written in Java (requires Java 8) • Integrated support for building Groovy-based applications • Emphasis on developer productivity • As few opinions as possible • Fast, self-contained, light-weight deployables 6
  • 7. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Simplest Hello World Example • Just a few lines of Groovy code required! 7
  • 8. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Simplest Hello World Example • Totally Tweetable! https://twitter.com/danveloper/status/608298173208100864 8
  • 9. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Java Hello World Example • Still, not very much needed at all… 9
  • 10. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Overview of Ratpack • Support for HTML templates with Groovy and Handlebars 10
  • 11. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Overview of Ratpack • Great for microservices! • First-class support for language agnostic transport 11
  • 12. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Overview of Ratpack • Non-blocking HTTP client 12
  • 13. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Overview of Ratpack • Fault tolerance for building distributed systems 13
  • 14. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Overview of Ratpack • Support for metric reporting with Dropwizard Metrics 14
  • 15. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Overview of Ratpack • Comprehensive configuration model 15
  • 16. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Overview of Ratpack • Support for persistent sessions 16
  • 17. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Overview of Ratpack • Robust security with Pac4j 17
  • 18. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Overview of Ratpack • Out of the box SSL support 18
  • 19. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Performance • Like most frameworks, Ratpack is CPU-bound (the more CPUs, the better) • Unlike most frameworks, Ratpack efficiently processes on each CPU 19 https://gist.github.com/danveloper/db888be3519966976368
  • 20. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Execution Model • The execution model in Ratpack is borne from the fact that the JVM has no inherent support for Continuations • Asynchronous programming is difficult • Async processing introduces non-determinism • Web applications require deterministic processing 20
  • 21. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Execution Model • Ratpack wants to make Async processing and programming a reliable and usable model for the JVM • By fitting into the execution model, applications garner confidence from a deterministic processing flow 21
  • 22. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ TPR/TPC Processing Model • How most JVM web frameworks work 22 Internet Web App new Thread().start() Blocking Processing Process and wait
  • 23. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ TPR/TPC Processing Model • In the thread-per-request (or thread-per-connection) model, you are limited by the amount of threads that you can create • Bringing the data from a request-taking thread and placing it into a processing thread incurs a context switch • The processing thread is where all your work is done, and is established until you respond • This is not performant at all, but it is an easy model to program in, and that’s why people use it 23
  • 24. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Ratpack Processing Model • How Ratpack works (4 CPU example) 24 Internet Event Loop Event Loop Event Loop Event Loop Handler Waiting for something? (db call, call to remote) Return thread to request-taking pool while we wait Respond One thread per CPU core
  • 25. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Ratpack Processing Model • Only establishes a single thread per CPU core • Processing doesn’t block the thread (if it needs to, then we can schedule it to the blocking thread pool) • While we wait for async responses to be fulfilled, the thread is able to process other requests • When we get the async response, processing continues on the same thread • No context switching in computation handlers, async processing responds when its work is done 25
  • 26. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Problems with Async Programming • Callbacks are obnoxious to work with • No good way to detect when waiting for async responses • Represents a temporal disconnect from the processing flow • Most async web frameworks start a timer when a request comes in, and if you don’t respond by the time that’s over, then it assumes you’re not going to 26
  • 27. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Problems with Async Programming 27 Callback HELL
  • 28. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Problems with Async Programming 28 With Ratpack Promises, you get guaranteed execution order without the need scoped callbacks. <1> - definitely happens 1st <2> - definitely happens 2nd <3> - definitely happens 3rd <4> - definitely happens 4th <5> - definitely happens 5th
  • 29. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Problems with Async Programming 29 In other async web frameworks: The clock is ticking for you to get that response out before the framework shuts you down
  • 30. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Problems with Async Programming 30 Execution |__stream |__marker |__flatMap(..) |__findByUsername |__stream |__marker |__flatMap(..) |__loadProfile |__stream |__marker |__flatMap(..) |__loadFriends |__stream |__marker |__flatMap(..) |__loadFriendPhotos |__stream |__marker |__render(..) |__then(..)
  • 31. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Execution Model • The overall execution is a parallel to the construct of a continuation • Each of the calls to a Promise represent a frame in the execution • Each of the Promise types represents a new processing stream in the execution • While async processing is taking place (ie. Promise is not fulfilled), the execution is suspended • When the execution is suspended, the processing thread is given back to the event loop to continue processing requests • When an async call returns, the execution is resumed 31
  • 32. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Execution Model • Most importantly, we know that when we hit the marker on a processing stream that the stream is done computing • The processing streams are supervised by Ratpack to know that a request is still processing • If your code doesn’t respond to a request, we don’t need to wait until the request times out to inform the client • If all the streams are done computing but no response has been sent, we are aware of that and can send an appropriate error back (no response sent) to the client 32
  • 33. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Execution Model • Ratpack’s execution model gives you much higher confidence in working with async programming • The Promise type makes async programming easier • Deterministic async processing gives added benefits for concurrency • You have better confidence when programming to async APIs with Ratpack • Fun fact: any API can be made asynchronous in Ratpack 33
  • 34. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Blocking Done Right • To make use of most 3rd party Java libraries, blocking will need to take place at some point • A prime example here is using JDBC • Since you can’t block on the request-taking thread, you will need to do blocking on a separate thread • Any non-trivial application will need to do blocking at some point… • Ratpack provides easy fixtures for Promise types to be scheduled for computation or blocking 34
  • 35. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Blocking Done Right 35
  • 36. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Dependency Injection • Ratpack is not tied to any particular dependency injection framework • DI is an abstract concept in Ratpack, components are registered via a Registry • Ratpack apps can be built entirely without any DI • Framework modularity is accomplished via Guice • 1st class support for Guice and Spring Boot 36
  • 37. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Registry • There are multiple registries in Ratpack • Provide components at different layers of the framework 37 Server Registry User Registry Context Registry Request Registry
  • 38. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Registry • Components can be bound to the user registry at start time 38
  • 39. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Registry • Registries can be built and cascaded at request time, and according to request attributes 39
  • 40. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Registry • Registries can be backed by Guice… 40
  • 41. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Registry • … or by Spring Boot… 41
  • 42. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Registry • … or both … 42
  • 43. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Dependency Injection • In Groovy, dependency injection can be accomplished by simply specifying the type as a closure argument 43
  • 44. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Dependency Injection • Taking a completely unopinionated approach to dependency injection allows implementations to be flexible • Can support nearly every component-providing backend • Gives you the ability to leverage the best parts of all available ecosystems • New Ratpack apps can readily fit into legacy infrastructures that do have opinions about this stuff 44
  • 45. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Build System Support • Ratpack is just a set of libraries, so any Java build system can build your project • Advanced integration with Gradle is provided through the ratpack-gradle plugin • Using Gradle is the easiest way to get started • Gradle plugin provides version-proper dependency resolution, so you don’t need to update versions as you upgrade your project 45
  • 46. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Build System Support • Just a set of libraries… 46
  • 47. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Build System Support • Advanced integration with Gradle… 47
  • 48. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Build System Support • Ratpack apps can be easily packaged for deployment with Gradle • Multiple options: fat jar, tarball, zip file • Gradle plugin applies the application plugin, so distributions and dependencies can easily be built and shipped with os start scripts • Fat JAR building is accomplished via the ShadowJar plugin 48
  • 49. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Developer Productivity • Development time hot reloading is provided via Gradle’s “continuous build” mode • Standalone Ratpack Groovy scripts are able to be reloaded when the development serverConfig option is true 49
  • 50. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ The Handler Chain • Denotes the edge of your application • Requests flow through the chain until reaching a handler than can provide a response • Two types of handlers: request flow and terminal • Request Flow handlers manage the direction the request takes through the chain • Terminal handlers process a request and respond to it 50
  • 51. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ The Handler Chain • Request flow handler 51
  • 52. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ The Handler Chain • Terminal handler 52
  • 53. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ The Handler Chain • Chain API provides semantic methods to bind a handler to an HTTP verb and optionally a path • get(..), post(..), put(..), patch(..), delete(..) methods will bind accordingly • Can also bind a handler that will be called for every incoming request with the all(..) and path(..) chain methods 53
  • 54. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Live Coding Demo Time 54
  • 55. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Questions? 55
  • 56. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Join the Community 56 http://slack-signup.ratpack.io/

Editor's Notes

  • #14: We provide a comprehensive integration with NetflixOSS’s Hystrix project Hystrix is a circuit breaker library where you can safely buil Hystrix helps you better build fault tolerant systems We even provide the ability to stream
  • #21: Non-blocking networking and asynchronous programming go hand-in-hand
  • #49: Demo: fatjar
  • #50: Demo: app.groovy
  • #51: Demo: app.groovy
  • #52: Demo: app.groovy
  • #53: Demo: app.groovy
  • #54: Demo: app.groovy
  • #55: Demo: app.groovy
  • #56: Demo: app.groovy
  • #57: Demo: app.groovy