SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Downloaden Sie, um offline zu lesen
Lari Hotari @lhotari
Pivotal Software, Inc.
Ratpack and
Grails 3
Agenda
• Grails 3 and Ratpack
• Why async?
• Modularity and micro service architectures
• Embrace Gradle
• Abstract packaging / deployment
• Reach outside the servlet container
• App profiles: Netty, Servlet, Batch, Hadoop
• Lightweight deployments, support micro
services
Grails 3
Why Netty / Ratpack?
Why async?
Amdahl's law
Programming model
• Declarative programming expresses the logic of
a computation without describing its control flow.
• It's programming without the call stack, the
programmer doesn't decide execution details.
• Examples: functional and reactive
programming, event / message based
execution, distributed parallel computation
algorithms like Map/Reduce
15 import ratpack.rx.RxRatpack
16 import ratpack.session.SessionModule
17 import ratpack.session.store.MapSessionsModule
18 import ratpack.session.store.SessionStorage
19
20 import static ratpack.groovy.Groovy.groovyTemplate
21 import static ratpack.groovy.Groovy.ratpack
22 import static ratpack.jackson.Jackson.json
23 import static ratpack.pac4j.internal.SessionConstants.USER_PROFILE
24
25 ratpack {
26 bindings {
27 bind DatabaseHealthCheck
28 add new CodaHaleMetricsModule().jvmMetrics().jmx().websocket().
29 healthChecks()
30 add new HikariModule([URL: "jdbc:h2:mem:dev;INIT=CREATE SCHEMA IF NOT
31 EXISTS DEV"], "org.h2.jdbcx.JdbcDataSource")
32 add new SqlModule()
33 add new JacksonModule()
34 add new BookModule()
35 add new RemoteControlModule()
36 add new SessionModule()
37 add new MapSessionsModule(10, 5)
38 add new Pac4jModule<>(new FormClient("/login", new
39 SimpleTestUsernamePasswordAuthenticator()), new
40 AuthPathAuthorizer())
41
42 init { BookService bookService ->
43 RxRatpack.initialize()
44 HystrixRatpack.initialize()
45 bookService.createTable()
46 }
47 }
48
49 handlers { BookService bookService ->
50
51 get {
52 bookService.all().toList().subscribe { List<Book> books ->
53 SessionStorage sessionStorage = request.get(SessionStorage)
54 UserProfile profile = sessionStorage.get(USER_PROFILE)
55 def username = profile?.getAttribute("username")
56
57 render groovyTemplate("listing.html",
58 username: username ?: "",
59 title: "Books",
60 books: books,
61 msg: request.queryParams.msg ?: "")
62 }
63 }
64
65 handler("create") {
66 byMethod {
67 get {
68 render groovyTemplate("create.html", title: "Create Book")
69 }
70 post {
71 Form form = parse(Form)
72 bookService.insert(
73 form.isbn,
74 form.get("quantity").asType(Long),
75 form.get("price").asType(BigDecimal)
76 ).single().subscribe { String isbn ->
77 redirect "/?msg=Book+$isbn+created"
78 }
79 }
80 }
81 }
82
83 handler("update/:isbn") {
84 def isbn = pathTokens["isbn"]
85
86 bookService.find(isbn).single().subscribe { Book book ->
87 if (book == null) {
88 clientError(404)
89 } else {
90 byMethod {
91 get {
92 render groovyTemplate("update.html", title:
93 "Update Book", book: book)
94 }
95 post {
96 Form form = parse(Form)
97 bookService.update(
98 isbn,
99 form.get("quantity").asType(Long),
100 form.get("price").asType(BigDecimal)
101 ) subscribe {
102 redirect "/?msg=Book+$isbn+updated"
103 }
104 }
105 }
106 }
107 }
108 }
109
110 post("delete/:isbn") {
111 def isbn = pathTokens["isbn"]
112 bookService.delete(isbn).subscribe {
113 redirect "/?msg=Book+$isbn+deleted"
114 }
115 }
116
117 prefix("api") {
118 get("books") {
119 bookService.all().toList().subscribe { List<Book> books ->
120 render json(books)
121 }
122 }
123
124 handler("book/:isbn?", registry.get(BookRestEndpoint))
81 }
82
83 handler("update/:isbn") {
84 def isbn = pathTokens["isbn"]
85
86 bookService.find(isbn).single().subscribe { Book book ->
87 if (book == null) {
88 clientError(404)
89 } else {
90 byMethod {
91 get {
92 render groovyTemplate("update.html", title:
93 "Update Book", book: book)
94 }
95 post {
96 Form form = parse(Form)
97 bookService.update(
98 isbn,
99 form.get("quantity").asType(Long),
100 form.get("price").asType(BigDecimal)
101 ) subscribe {
102 redirect "/?msg=Book+$isbn+updated"
103 }
104 }
105 }
106 }
107 }
108 }
109
110 post("delete/:isbn") {
111 def isbn = pathTokens["isbn"]
112 bookService.delete(isbn).subscribe {
113 redirect "/?msg=Book+$isbn+deleted"
source: https://github.com/ratpack/example-books/blob/master/src/ratpack/Ratpack.groovy
Ratpack application
consists of
functional handler
chains
Ratpack applications
• Ratpacks comes with Guice for dependency injection
• Guice modules are also used as the plugin system for
Ratpack
• Examples of Ratpack module contributions:
• Integrations to RxJava and Reactor. Can be used for
async composition and preventing "callback hell".
• Integration to Netflix Hystrix for adding error resilience
functionality . f.e., Circuit-breaker pattern impl.
Demo
Ratpack and Grails (GORM) used together
• https://github.com/lhotari/ratpack-gorm-example
• Spring Boot embedded in Ratpack, running
GORM
Modularity
• logical partitioning of the "software design"
• allows complex software to be manageable for
the purpose of implementation and maintenance
Coupling and Cohesion
• Coupling and cohesion are measures for
describing how easy it will be to change the
behaviour of some element in a system
• Modules are coupled if a change in one forces a
change in a the other
• A module's cohesion is a measure of whether it's
responsibilities form a meaningful unit
source: GOOS book
• Low coupling between modules ⟹ easier to
change
• High cohesion within module ⟹ single
responsibility
Microservice denition
by James Lewis
• Each application only does one thing
• Small enough to fit in your head
• Small enough that you can throw them away
• Embedded web container
• Packaged as a single executable jar
• Use HTTP and HATEOAS to decouple services
• Each app exposes metrics about itself
–Arnon Rotem-Gal-Oz, Practical SOA
“Nanoservice is an Anti-pattern where a
service is too ne grained. Nanoservice is a
service whose overhead (communications,
maintenance etc.) out-weights its utility.”
Polygot persistence
• Common principle is that each service owns it's data -
there is no shared database across multiple services.
• If this principle is followed, it usually means switching
to Hexagonal architecture, where persistence is an
integration and not part of the core.
• "Start with the events and behaviour instead of the
database."
• Data consistency models in distributed systems
Brooks: "No silver bullet"
• Essential complexity
• complexity that you cannot escape
• Accidental complexity
• we could be adding complexity by bad design
- Google's "Solve for X"
“You don't spend your time
being bothered that you can't
teleport from here to Japan,
because there's a part of you
that thinks it's impossible. !
Moonshot thinking is choosing
to be bothered by that.”
Modular monoliths
• Modular monoliths are composed of loosely coupled
modules of single responsibility
• Enabling the 3rd way (after monoliths and
microservices) for building applications on the JVM
across different libraries and frameworks
• Modules can be turned into true micro services when
needed - instead of introducing accidental complexity
to projects that don't really require micro services in
the beginning, but could benet of them later
The monoliths in the micro
services architecture
Single Page
App in
Browser
API Gateway
service
Âľservice
A
SAAS Service
A
SAAS Service
B
Âľservice
B
Âľservice
C
Âľservice
D
Âľservice
E
Âľservice
F
"If you built it..."
 pretotyping.org
“Make sure you are building the
right it before you build it right."
!
"Fail fast ... and Often"
Lari Hotari @lhotari
Pivotal Software, Inc.
Thank you!

Weitere ähnliche Inhalte

Was ist angesagt?

Welcome To CloudLand! Intro to the Cloud Native Landscape
Welcome To CloudLand! Intro to the Cloud Native LandscapeWelcome To CloudLand! Intro to the Cloud Native Landscape
Welcome To CloudLand! Intro to the Cloud Native LandscapeKaslin Fields
 
The 6 Rules for Modernizing Your Legacy Java Monolith with Microservices
The 6 Rules for Modernizing Your Legacy Java Monolith with MicroservicesThe 6 Rules for Modernizing Your Legacy Java Monolith with Microservices
The 6 Rules for Modernizing Your Legacy Java Monolith with MicroservicesLightbend
 
Designing a Service Mesh with Kafka and Sagas | David Navalho, Marionete and ...
Designing a Service Mesh with Kafka and Sagas | David Navalho, Marionete and ...Designing a Service Mesh with Kafka and Sagas | David Navalho, Marionete and ...
Designing a Service Mesh with Kafka and Sagas | David Navalho, Marionete and ...HostedbyConfluent
 
Cloud Computing Principles and Paradigms: 7 enhancing cloud computing environ...
Cloud Computing Principles and Paradigms: 7 enhancing cloud computing environ...Cloud Computing Principles and Paradigms: 7 enhancing cloud computing environ...
Cloud Computing Principles and Paradigms: 7 enhancing cloud computing environ...Majid Hajibaba
 
The hardest part of microservices: your data
The hardest part of microservices: your dataThe hardest part of microservices: your data
The hardest part of microservices: your dataChristian Posta
 
Cloud Computing Principles and Paradigms: 6 on the management of virtual mach...
Cloud Computing Principles and Paradigms: 6 on the management of virtual mach...Cloud Computing Principles and Paradigms: 6 on the management of virtual mach...
Cloud Computing Principles and Paradigms: 6 on the management of virtual mach...Majid Hajibaba
 
QCon NYC: Distributed systems in practice, in theory
QCon NYC: Distributed systems in practice, in theoryQCon NYC: Distributed systems in practice, in theory
QCon NYC: Distributed systems in practice, in theoryAysylu Greenberg
 
[WSO2Con USA 2018] Deploying Applications in K8S and Docker
[WSO2Con USA 2018] Deploying Applications in K8S and Docker[WSO2Con USA 2018] Deploying Applications in K8S and Docker
[WSO2Con USA 2018] Deploying Applications in K8S and DockerWSO2
 
Clocker Now and Next
Clocker Now and NextClocker Now and Next
Clocker Now and NextAndrew Kennedy
 

Was ist angesagt? (9)

Welcome To CloudLand! Intro to the Cloud Native Landscape
Welcome To CloudLand! Intro to the Cloud Native LandscapeWelcome To CloudLand! Intro to the Cloud Native Landscape
Welcome To CloudLand! Intro to the Cloud Native Landscape
 
The 6 Rules for Modernizing Your Legacy Java Monolith with Microservices
The 6 Rules for Modernizing Your Legacy Java Monolith with MicroservicesThe 6 Rules for Modernizing Your Legacy Java Monolith with Microservices
The 6 Rules for Modernizing Your Legacy Java Monolith with Microservices
 
Designing a Service Mesh with Kafka and Sagas | David Navalho, Marionete and ...
Designing a Service Mesh with Kafka and Sagas | David Navalho, Marionete and ...Designing a Service Mesh with Kafka and Sagas | David Navalho, Marionete and ...
Designing a Service Mesh with Kafka and Sagas | David Navalho, Marionete and ...
 
Cloud Computing Principles and Paradigms: 7 enhancing cloud computing environ...
Cloud Computing Principles and Paradigms: 7 enhancing cloud computing environ...Cloud Computing Principles and Paradigms: 7 enhancing cloud computing environ...
Cloud Computing Principles and Paradigms: 7 enhancing cloud computing environ...
 
The hardest part of microservices: your data
The hardest part of microservices: your dataThe hardest part of microservices: your data
The hardest part of microservices: your data
 
Cloud Computing Principles and Paradigms: 6 on the management of virtual mach...
Cloud Computing Principles and Paradigms: 6 on the management of virtual mach...Cloud Computing Principles and Paradigms: 6 on the management of virtual mach...
Cloud Computing Principles and Paradigms: 6 on the management of virtual mach...
 
QCon NYC: Distributed systems in practice, in theory
QCon NYC: Distributed systems in practice, in theoryQCon NYC: Distributed systems in practice, in theory
QCon NYC: Distributed systems in practice, in theory
 
[WSO2Con USA 2018] Deploying Applications in K8S and Docker
[WSO2Con USA 2018] Deploying Applications in K8S and Docker[WSO2Con USA 2018] Deploying Applications in K8S and Docker
[WSO2Con USA 2018] Deploying Applications in K8S and Docker
 
Clocker Now and Next
Clocker Now and NextClocker Now and Next
Clocker Now and Next
 

Andere mochten auch

Forex AutoPilot
Forex AutoPilotForex AutoPilot
Forex AutoPilotRosli Shafiee
 
Ratpack Web Framework
Ratpack Web FrameworkRatpack Web Framework
Ratpack Web FrameworkDaniel Woods
 
High Performance Microservices with Ratpack and Spring Boot
High Performance Microservices with Ratpack and Spring BootHigh Performance Microservices with Ratpack and Spring Boot
High Performance Microservices with Ratpack and Spring BootDaniel Woods
 
Ratpack and Grails 3
 Ratpack and Grails 3 Ratpack and Grails 3
Ratpack and Grails 3GR8Conf
 
Ingesting Drone Data into Big Data Platforms
Ingesting Drone Data into Big Data Platforms Ingesting Drone Data into Big Data Platforms
Ingesting Drone Data into Big Data Platforms Timothy Spann
 
CSS Grid Layout
CSS Grid LayoutCSS Grid Layout
CSS Grid LayoutRachel Andrew
 

Andere mochten auch (6)

Forex AutoPilot
Forex AutoPilotForex AutoPilot
Forex AutoPilot
 
Ratpack Web Framework
Ratpack Web FrameworkRatpack Web Framework
Ratpack Web Framework
 
High Performance Microservices with Ratpack and Spring Boot
High Performance Microservices with Ratpack and Spring BootHigh Performance Microservices with Ratpack and Spring Boot
High Performance Microservices with Ratpack and Spring Boot
 
Ratpack and Grails 3
 Ratpack and Grails 3 Ratpack and Grails 3
Ratpack and Grails 3
 
Ingesting Drone Data into Big Data Platforms
Ingesting Drone Data into Big Data Platforms Ingesting Drone Data into Big Data Platforms
Ingesting Drone Data into Big Data Platforms
 
CSS Grid Layout
CSS Grid LayoutCSS Grid Layout
CSS Grid Layout
 

Ähnlich wie Ratpack and Grails 3

Microservice message routing on Kubernetes
Microservice message routing on KubernetesMicroservice message routing on Kubernetes
Microservice message routing on KubernetesFrans van Buul
 
Exploring Twitter's Finagle technology stack for microservices
Exploring Twitter's Finagle technology stack for microservicesExploring Twitter's Finagle technology stack for microservices
Exploring Twitter's Finagle technology stack for microservices💡 Tomasz Kogut
 
AngularJS
AngularJSAngularJS
AngularJSYogesh L
 
Reactive Design Patterns: a talk by Typesafe's Dr. Roland Kuhn
Reactive Design Patterns: a talk by Typesafe's Dr. Roland KuhnReactive Design Patterns: a talk by Typesafe's Dr. Roland Kuhn
Reactive Design Patterns: a talk by Typesafe's Dr. Roland KuhnZalando Technology
 
The Meteor Framework
The Meteor FrameworkThe Meteor Framework
The Meteor FrameworkDamien Magoni
 
Microservices with Apache Camel, Docker and Fabric8 v2
Microservices with Apache Camel, Docker and Fabric8 v2Microservices with Apache Camel, Docker and Fabric8 v2
Microservices with Apache Camel, Docker and Fabric8 v2Christian Posta
 
Mcknight well built extensions
Mcknight well built extensionsMcknight well built extensions
Mcknight well built extensionsRichard McKnight
 
Lagom : Reactive microservice framework
Lagom : Reactive microservice frameworkLagom : Reactive microservice framework
Lagom : Reactive microservice frameworkFabrice Sznajderman
 
PHP At 5000 Requests Per Second: Hootsuite’s Scaling Story
PHP At 5000 Requests Per Second: Hootsuite’s Scaling StoryPHP At 5000 Requests Per Second: Hootsuite’s Scaling Story
PHP At 5000 Requests Per Second: Hootsuite’s Scaling Storyvanphp
 
Andrii Sliusar "Module Architecture of React-Redux Applications"
Andrii Sliusar "Module Architecture of React-Redux Applications"Andrii Sliusar "Module Architecture of React-Redux Applications"
Andrii Sliusar "Module Architecture of React-Redux Applications"LogeekNightUkraine
 
Jclouds Intro
Jclouds IntroJclouds Intro
Jclouds Introguesta31f61
 
BISSA: Empowering Web gadget Communication with Tuple Spaces
BISSA: Empowering Web gadget Communication with Tuple SpacesBISSA: Empowering Web gadget Communication with Tuple Spaces
BISSA: Empowering Web gadget Communication with Tuple SpacesSrinath Perera
 
Developing Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's GuideDeveloping Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's GuideMohanraj Thirumoorthy
 
SpringPeople - Introduction to Cloud Computing
SpringPeople - Introduction to Cloud ComputingSpringPeople - Introduction to Cloud Computing
SpringPeople - Introduction to Cloud ComputingSpringPeople
 
Managing your camels in the cloud with CI/CD
Managing your camels in the cloud with CI/CDManaging your camels in the cloud with CI/CD
Managing your camels in the cloud with CI/CDChristian Posta
 
'How to build efficient backend based on microservice architecture' by Anton ...
'How to build efficient backend based on microservice architecture' by Anton ...'How to build efficient backend based on microservice architecture' by Anton ...
'How to build efficient backend based on microservice architecture' by Anton ...OdessaJS Conf
 
Software Development: Beyond Training wheels
Software Development: Beyond Training wheelsSoftware Development: Beyond Training wheels
Software Development: Beyond Training wheelsNaveenkumar Muguda
 
Backbone JS for mobile apps
Backbone JS for mobile appsBackbone JS for mobile apps
Backbone JS for mobile appsIvano Malavolta
 
[2015/2016] Backbone JS
[2015/2016] Backbone JS[2015/2016] Backbone JS
[2015/2016] Backbone JSIvano Malavolta
 

Ähnlich wie Ratpack and Grails 3 (20)

Microservice message routing on Kubernetes
Microservice message routing on KubernetesMicroservice message routing on Kubernetes
Microservice message routing on Kubernetes
 
Exploring Twitter's Finagle technology stack for microservices
Exploring Twitter's Finagle technology stack for microservicesExploring Twitter's Finagle technology stack for microservices
Exploring Twitter's Finagle technology stack for microservices
 
AngularJS
AngularJSAngularJS
AngularJS
 
Reactive Design Patterns: a talk by Typesafe's Dr. Roland Kuhn
Reactive Design Patterns: a talk by Typesafe's Dr. Roland KuhnReactive Design Patterns: a talk by Typesafe's Dr. Roland Kuhn
Reactive Design Patterns: a talk by Typesafe's Dr. Roland Kuhn
 
The Meteor Framework
The Meteor FrameworkThe Meteor Framework
The Meteor Framework
 
Microservices with Apache Camel, Docker and Fabric8 v2
Microservices with Apache Camel, Docker and Fabric8 v2Microservices with Apache Camel, Docker and Fabric8 v2
Microservices with Apache Camel, Docker and Fabric8 v2
 
Mcknight well built extensions
Mcknight well built extensionsMcknight well built extensions
Mcknight well built extensions
 
Lagom : Reactive microservice framework
Lagom : Reactive microservice frameworkLagom : Reactive microservice framework
Lagom : Reactive microservice framework
 
PHP At 5000 Requests Per Second: Hootsuite’s Scaling Story
PHP At 5000 Requests Per Second: Hootsuite’s Scaling StoryPHP At 5000 Requests Per Second: Hootsuite’s Scaling Story
PHP At 5000 Requests Per Second: Hootsuite’s Scaling Story
 
Andrii Sliusar "Module Architecture of React-Redux Applications"
Andrii Sliusar "Module Architecture of React-Redux Applications"Andrii Sliusar "Module Architecture of React-Redux Applications"
Andrii Sliusar "Module Architecture of React-Redux Applications"
 
Jclouds Intro
Jclouds IntroJclouds Intro
Jclouds Intro
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
BISSA: Empowering Web gadget Communication with Tuple Spaces
BISSA: Empowering Web gadget Communication with Tuple SpacesBISSA: Empowering Web gadget Communication with Tuple Spaces
BISSA: Empowering Web gadget Communication with Tuple Spaces
 
Developing Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's GuideDeveloping Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's Guide
 
SpringPeople - Introduction to Cloud Computing
SpringPeople - Introduction to Cloud ComputingSpringPeople - Introduction to Cloud Computing
SpringPeople - Introduction to Cloud Computing
 
Managing your camels in the cloud with CI/CD
Managing your camels in the cloud with CI/CDManaging your camels in the cloud with CI/CD
Managing your camels in the cloud with CI/CD
 
'How to build efficient backend based on microservice architecture' by Anton ...
'How to build efficient backend based on microservice architecture' by Anton ...'How to build efficient backend based on microservice architecture' by Anton ...
'How to build efficient backend based on microservice architecture' by Anton ...
 
Software Development: Beyond Training wheels
Software Development: Beyond Training wheelsSoftware Development: Beyond Training wheels
Software Development: Beyond Training wheels
 
Backbone JS for mobile apps
Backbone JS for mobile appsBackbone JS for mobile apps
Backbone JS for mobile apps
 
[2015/2016] Backbone JS
[2015/2016] Backbone JS[2015/2016] Backbone JS
[2015/2016] Backbone JS
 

KĂźrzlich hochgeladen

Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 

KĂźrzlich hochgeladen (20)

Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 

Ratpack and Grails 3

  • 1. Lari Hotari @lhotari Pivotal Software, Inc. Ratpack and Grails 3
  • 2. Agenda • Grails 3 and Ratpack • Why async? • Modularity and micro service architectures
  • 3. • Embrace Gradle • Abstract packaging / deployment • Reach outside the servlet container • App proles: Netty, Servlet, Batch, Hadoop • Lightweight deployments, support micro services Grails 3
  • 4.
  • 5. Why Netty / Ratpack? Why async?
  • 7. Programming model • Declarative programming expresses the logic of a computation without describing its control flow. • It's programming without the call stack, the programmer doesn't decide execution details. • Examples: functional and reactive programming, event / message based execution, distributed parallel computation algorithms like Map/Reduce
  • 8. 15 import ratpack.rx.RxRatpack 16 import ratpack.session.SessionModule 17 import ratpack.session.store.MapSessionsModule 18 import ratpack.session.store.SessionStorage 19 20 import static ratpack.groovy.Groovy.groovyTemplate 21 import static ratpack.groovy.Groovy.ratpack 22 import static ratpack.jackson.Jackson.json 23 import static ratpack.pac4j.internal.SessionConstants.USER_PROFILE 24 25 ratpack { 26 bindings { 27 bind DatabaseHealthCheck 28 add new CodaHaleMetricsModule().jvmMetrics().jmx().websocket(). 29 healthChecks() 30 add new HikariModule([URL: "jdbc:h2:mem:dev;INIT=CREATE SCHEMA IF NOT 31 EXISTS DEV"], "org.h2.jdbcx.JdbcDataSource") 32 add new SqlModule() 33 add new JacksonModule() 34 add new BookModule() 35 add new RemoteControlModule() 36 add new SessionModule() 37 add new MapSessionsModule(10, 5) 38 add new Pac4jModule<>(new FormClient("/login", new 39 SimpleTestUsernamePasswordAuthenticator()), new 40 AuthPathAuthorizer()) 41 42 init { BookService bookService -> 43 RxRatpack.initialize() 44 HystrixRatpack.initialize() 45 bookService.createTable() 46 } 47 } 48 49 handlers { BookService bookService -> 50 51 get { 52 bookService.all().toList().subscribe { List<Book> books -> 53 SessionStorage sessionStorage = request.get(SessionStorage) 54 UserProfile profile = sessionStorage.get(USER_PROFILE) 55 def username = profile?.getAttribute("username") 56 57 render groovyTemplate("listing.html", 58 username: username ?: "", 59 title: "Books", 60 books: books, 61 msg: request.queryParams.msg ?: "") 62 } 63 } 64 65 handler("create") { 66 byMethod { 67 get { 68 render groovyTemplate("create.html", title: "Create Book") 69 } 70 post { 71 Form form = parse(Form) 72 bookService.insert( 73 form.isbn, 74 form.get("quantity").asType(Long), 75 form.get("price").asType(BigDecimal) 76 ).single().subscribe { String isbn -> 77 redirect "/?msg=Book+$isbn+created" 78 } 79 } 80 } 81 } 82 83 handler("update/:isbn") { 84 def isbn = pathTokens["isbn"] 85 86 bookService.find(isbn).single().subscribe { Book book -> 87 if (book == null) { 88 clientError(404) 89 } else { 90 byMethod { 91 get { 92 render groovyTemplate("update.html", title: 93 "Update Book", book: book) 94 } 95 post { 96 Form form = parse(Form) 97 bookService.update( 98 isbn, 99 form.get("quantity").asType(Long), 100 form.get("price").asType(BigDecimal) 101 ) subscribe { 102 redirect "/?msg=Book+$isbn+updated" 103 } 104 } 105 } 106 } 107 } 108 } 109 110 post("delete/:isbn") { 111 def isbn = pathTokens["isbn"] 112 bookService.delete(isbn).subscribe { 113 redirect "/?msg=Book+$isbn+deleted" 114 } 115 } 116 117 prefix("api") { 118 get("books") { 119 bookService.all().toList().subscribe { List<Book> books -> 120 render json(books) 121 } 122 } 123 124 handler("book/:isbn?", registry.get(BookRestEndpoint)) 81 } 82 83 handler("update/:isbn") { 84 def isbn = pathTokens["isbn"] 85 86 bookService.find(isbn).single().subscribe { Book book -> 87 if (book == null) { 88 clientError(404) 89 } else { 90 byMethod { 91 get { 92 render groovyTemplate("update.html", title: 93 "Update Book", book: book) 94 } 95 post { 96 Form form = parse(Form) 97 bookService.update( 98 isbn, 99 form.get("quantity").asType(Long), 100 form.get("price").asType(BigDecimal) 101 ) subscribe { 102 redirect "/?msg=Book+$isbn+updated" 103 } 104 } 105 } 106 } 107 } 108 } 109 110 post("delete/:isbn") { 111 def isbn = pathTokens["isbn"] 112 bookService.delete(isbn).subscribe { 113 redirect "/?msg=Book+$isbn+deleted" source: https://github.com/ratpack/example-books/blob/master/src/ratpack/Ratpack.groovy Ratpack application consists of functional handler chains
  • 9. Ratpack applications • Ratpacks comes with Guice for dependency injection • Guice modules are also used as the plugin system for Ratpack • Examples of Ratpack module contributions: • Integrations to RxJava and Reactor. Can be used for async composition and preventing "callback hell". • Integration to Netflix Hystrix for adding error resilience functionality . f.e., Circuit-breaker pattern impl.
  • 10. Demo Ratpack and Grails (GORM) used together • https://github.com/lhotari/ratpack-gorm-example • Spring Boot embedded in Ratpack, running GORM
  • 11.
  • 12. Modularity • logical partitioning of the "software design" • allows complex software to be manageable for the purpose of implementation and maintenance
  • 13. Coupling and Cohesion • Coupling and cohesion are measures for describing how easy it will be to change the behaviour of some element in a system • Modules are coupled if a change in one forces a change in a the other • A module's cohesion is a measure of whether it's responsibilities form a meaningful unit source: GOOS book
  • 14. • Low coupling between modules ⟹ easier to change • High cohesion within module ⟹ single responsibility
  • 15. Microservice denition by James Lewis • Each application only does one thing • Small enough to t in your head • Small enough that you can throw them away • Embedded web container • Packaged as a single executable jar • Use HTTP and HATEOAS to decouple services • Each app exposes metrics about itself
  • 16. –Arnon Rotem-Gal-Oz, Practical SOA “Nanoservice is an Anti-pattern where a service is too ne grained. Nanoservice is a service whose overhead (communications, maintenance etc.) out-weights its utility.”
  • 17. Polygot persistence • Common principle is that each service owns it's data - there is no shared database across multiple services. • If this principle is followed, it usually means switching to Hexagonal architecture, where persistence is an integration and not part of the core. • "Start with the events and behaviour instead of the database." • Data consistency models in distributed systems
  • 18. Brooks: "No silver bullet" • Essential complexity • complexity that you cannot escape • Accidental complexity • we could be adding complexity by bad design
  • 19. - Google's "Solve for X" “You don't spend your time being bothered that you can't teleport from here to Japan, because there's a part of you that thinks it's impossible. ! Moonshot thinking is choosing to be bothered by that.”
  • 20. Modular monoliths • Modular monoliths are composed of loosely coupled modules of single responsibility • Enabling the 3rd way (after monoliths and microservices) for building applications on the JVM across different libraries and frameworks • Modules can be turned into true micro services when needed - instead of introducing accidental complexity to projects that don't really require micro services in the beginning, but could benet of them later
  • 21. The monoliths in the micro services architecture Single Page App in Browser API Gateway service Âľservice A SAAS Service A SAAS Service B Âľservice B Âľservice C Âľservice D Âľservice E Âľservice F
  • 22. "If you built it..."
  • 23.  pretotyping.org “Make sure you are building the right it before you build it right." ! "Fail fast ... and Often"
  • 24. Lari Hotari @lhotari Pivotal Software, Inc. Thank you!