SlideShare una empresa de Scribd logo
1 de 79
Bekir Oguz
Merlijn van Ittersum
Designing process flows with
#Baker
Amsterdam.Scala Meetup
September 2017
How to bake a pizza?
2
How to bake a pizza?
3
How to bake a pizza?
4
Why?
It is hard to develop complex orchestration APIs
6
7
We need a cleaner way to allow design changes in complex APIs
8
Example: initial design of the API
A B C D E
1 2 3 4 5
A B C D E
1 2 3 4 5
We need a cleaner way to allow design changes in complex APIs
9
Example: API after one design change
A B C D E
1 2 3 4 5
We need a cleaner way to allow design changes in complex APIs
10
Example: API after ten design changes
We need a cleaner way to allow design changes in complex APIs
11
Example: API after ten design changes
A B C D E
1 2 3 4 5
Open Kinder- / Jongerenrekening Open Groei Groter rekening Another Product
Verify customer rules Verify customer rules Verify customer rules
Register individual Register individual Register Individual
Send a present Send a present Not applicable
Send a message to the customer Send a message to the customer Send a message to the customer
Open a payments account Open a savings account Open a payments account
Enable billing Enable billing Assign package
There is more need for reuse between teams
12
13
What?
Baker is a Scala library that simplifies the development of complex orchestration logic.
What? Baker!
github.com/ing-bank/baker
Intermediate
Languagevalidate
compile
execute
Baker runtime
Recipe
Event
Ingredient
Interaction
Defining ingredients
17
case class CustomerInfo(name: String, address: String, email: String)
// ingredients
val customerInfo = Ingredient[CustomerInfo]("customerInfo")
val trackingId = Ingredient[String]("trackingId")
val order = Ingredient[String]("order")
Defining events
18
// events
val goodsShipped = Event("GoodsShipped", trackingId)
val orderPlaced = Event("OrderPlaced", order)
val paymentMade = Event("PaymentMade")
val valid = Event("Valid")
val sorry = Event("Sorry")
Defining interactions
19
// interactions
val validateOrder = Interaction(
name = "ValidateOrder",
inputIngredients = order,
output = FiresOneOfEvents(valid, sorry)
)
val shipGoods = Interaction(
name = "ShipGoods",
inputIngredients = Ingredients(goods, customerInfo),
output = FiresOneOfEvents(goodsShipped)
)
Defining a recipe
20
// recipe
val webShopRecipe: Recipe =
Recipe("WebShop")
.withInteractions(
validateOrder,
manufactureGoods
.withRequiredEvents(valid, paymentMade),
shipGoods,
sendInvoice
.withRequiredEvent(goodsShipped)
)
.withSensoryEvents(
customerInfoReceived,
orderPlaced,
paymentMade)
Compile the recipe
21
// compiles the recipe
val compiledRecipe = RecipeCompiler.compileRecipe(webShopRecipe)
// list of validation errors
val errors: Seq[String] = compiledRecipe.validationErrors
// .dot (graphviz notation) representation
val visualization: String = compiledRecipe.getRecipeVisualization
Visualising the recipe
22
A Baker instance can be created from the valid recipe.
It takes care of the execution of the recipe.
The only thing left is to provide sensory events to Baker!
Baker runtime
23
Initializing Baker instance
24
You can create a new Baker instance by providing the recipe and implementations of the
interactions:
val compiledRecipe = RecipeCompiler.compileRecipe(webShopRecipe)
val validateOrderImpl = validateOrder implement {
(order: String) => {
// Some logic here
valid.instance() // or maybe invalid event to be returned
}
}
val implementations =
Seq(validateOrderImpl, manufactureGoodsImpl, sendInvoiceImpl, shipGoodsImpl)
val baker = new Baker(compiledRecipe, implementations)
For each client request you do the following:
Firing events
25
val processId = UUID.randomUUID().toString
baker.bake(processId)
baker.handleEvent(processId, orderPlaced.instance(testOrder))
baker.handleEvent(processId, paymentMade.instance())
baker.handleEvent(processId, customerInfoReceived.instance(testCustomerInfoData))
val actualIngredients: Map[String, Any] = baker.getIngredients(processId)
val actualEvents: Seq[RuntimeEvent] = baker.events(processId)
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
1. It is hard to develop complex orchestration APIs
2. We need a cleaner way to allow design changes in complex APIs
3. There is more need for reuse between teams
Does Baker help with the Why?
42
1. It is hard to develop complex orchestration APIs
With Baker, you think about what you want, not about the order.
Baker can validate the recipe for you.
Clear insight in the current model by visualising the recipe.
2. We need a cleaner way to allow design changes in complex APIs
3. There is more need for reuse between teams
Does Baker help with the Why?
43
1. It is hard to develop complex orchestration APIs
With Baker, you think about what you want, not about the order.
Baker can validate the recipe for you.
Clear insight in the current model by visualising the recipe.
2. We need a cleaner way to allow design changes in complex APIs
Baker links the interactions when compiling the recipe.
If interactions are added, removed or changed, Baker will update the model accordingly.
3. There is more need for reuse between teams
Does Baker help with the Why?
44
1. It is hard to develop complex orchestration APIs
With Baker, you think about what you want, not about the order.
Baker can validate the recipe for you.
Clear insight in the current model by visualising the recipe.
2. We need a cleaner way to allow design changes in complex APIs
Baker links the interactions when compiling the recipe.
If interactions are added, removed or changed, Baker will update the model accordingly.
3. There is more need for reuse between teams
The possibility to share interactions, ingredients and events between recipes allows for
much more reuse of code among teams.
Does Baker help with the Why?
45
How?
Baker is powered by
47
PetriNet
Process logic is isolated in an Akka actor, this gives us the following benefits:
• Event sourcing through persistent actors
• Supporting many data stores, i.e. cassandra
• Distributing actors with Cluster Sharding
Akka
48
On creation of the Baker instance, the recipe is compiled into a Petri net.
A Petri net is a mathematical model that can be used for reasoning about concurrency.
This Petri net is then used to determine when & what interactions to execute.
PetriNet
49
Execution Semantics: Token passing
50
t1 t2 t3
Execution Semantics: Token passing
51
t1 t2 t3
Execution Semantics: Token passing
52
t1 t2 t3
Execution Semantics: Token passing
53
t1 t2 t3
Execution Semantics: Concurrency
54
t1
t3
t4
t5
t2
Execution Semantics: Concurrency
55
t1
t3
t4
t5
t2
Choice
Execution Semantics: Concurrency
56
t1
t3
t4
t5
t2
Parallel split
Execution Semantics: Concurrency
57
t1
t3
t4
t5
t2
Parallel paths
Execution Semantics: Concurrency
58
t1
t3
t4
t5
t2
Parallel paths
Execution Semantics: Concurrency
59
t1
t3
t4
t5
t2
synchronization
• Simple, uses only a few concepts and components
• Exact mathematical definition of execution semantics
• Intuitive graphical notation
• Well-developed mathematical theory for process analysis
Advantages
60
Reachability
61
?
A
B
Unreachable code
62
A
B
Detect cycles
63
Path traversal time
64
Average traversal time: 10 seconds
A
B
Identifying bottlenecks
65
Takes 70% of the time
A
B
Path prediction
66
83%
17%
A
B
67
Features
Recipe Runtime
68
Features
Recipe
Developer friendly Java/Scala dsl
Runtime
69
Features
Recipe
Developer friendly Java/Scala dsl
Compile-time recipe validation
Runtime
70
Features
Recipe
Developer friendly Java/Scala dsl
Compile-time recipe validation
Type safety
Runtime
71
Features
Recipe
Developer friendly Java/Scala dsl
Compile-time recipe validation
Type safety
Runtime
Execution of the recipe, powered by
akka and petrinet model
72
Features
Recipe
Developer friendly Java/Scala dsl
Compile-time recipe validation
Type safety
Runtime
Execution of the recipe, powered by
akka and petrinet model
Persisted state through event sourcing
73
Features
Recipe
Developer friendly Java/Scala dsl
Compile-time recipe validation
Type safety
Runtime
Execution of the recipe, powered by
akka and petrinet model
Persisted state through event sourcing
Data encryption
74
Features
Recipe
Developer friendly Java/Scala dsl
Compile-time recipe validation
Type safety
Runtime
Execution of the recipe, powered by
akka and petrinet model
Persisted state through event sourcing
Data encryption
Automatic retries on technical failures
75
Features
Recipe
Developer friendly Java/Scala dsl
Compile-time recipe validation
Type safety
Runtime
Execution of the recipe, powered by
akka and petrinet model
Persisted state through event sourcing
Data encryption
Automatic retries on technical failures
Parallel execution of paths
Property Based Testing
76
Property Based Testing
77
val recipeGen: Gen[Recipe] = for {
name <- nameGen
sensoryEvents <- Gen.listOf(eventGen) suchThat (_.nonEmpty)
interactions <- interactionsGen(sensoryEvents) suchThat (_.nonEmpty)
} yield Recipe(name)
//turn the lists into var args
.withSensoryEvents(sensoryEvents: _*)
.withInteractions(interactions.toList: _*)
Property Based Testing
78
forAll(recipeGen) { recipe =>
val validations = ValidationSettings(
allowCycles = false,
allowNonExecutableInteractions = false)
val compiledRecipe = RecipeCompiler.compileRecipe(recipe, validations)
if (compiledRecipe.validationErrors.nonEmpty) {
logRecipeStats(recipe)
logCompiledRecipeStats(compiledRecipe)
}
compiledRecipe.validationErrors.isEmpty
}
Questions?

Más contenido relacionado

La actualidad más candente

Boost Your Server - the Plesk Roadmap 2022 @Cloudfest 2022
Boost Your Server - the Plesk Roadmap 2022 @Cloudfest 2022Boost Your Server - the Plesk Roadmap 2022 @Cloudfest 2022
Boost Your Server - the Plesk Roadmap 2022 @Cloudfest 2022Plesk
 
Managing data workflows with Luigi
Managing data workflows with LuigiManaging data workflows with Luigi
Managing data workflows with LuigiTeemu Kurppa
 
ROS 2 deployment in K8s: DDS Router as WAN comms enabler
ROS 2 deployment in K8s: DDS Router as WAN comms enablerROS 2 deployment in K8s: DDS Router as WAN comms enabler
ROS 2 deployment in K8s: DDS Router as WAN comms enablereProsima
 
Seminar Presentation Hadoop
Seminar Presentation HadoopSeminar Presentation Hadoop
Seminar Presentation HadoopVarun Narang
 
Introduction To RDF and RDFS
Introduction To RDF and RDFSIntroduction To RDF and RDFS
Introduction To RDF and RDFSNilesh Wagmare
 

La actualidad más candente (6)

Boost Your Server - the Plesk Roadmap 2022 @Cloudfest 2022
Boost Your Server - the Plesk Roadmap 2022 @Cloudfest 2022Boost Your Server - the Plesk Roadmap 2022 @Cloudfest 2022
Boost Your Server - the Plesk Roadmap 2022 @Cloudfest 2022
 
Managing data workflows with Luigi
Managing data workflows with LuigiManaging data workflows with Luigi
Managing data workflows with Luigi
 
Detecting Paraphrases in Marathi Language
Detecting Paraphrases in Marathi LanguageDetecting Paraphrases in Marathi Language
Detecting Paraphrases in Marathi Language
 
ROS 2 deployment in K8s: DDS Router as WAN comms enabler
ROS 2 deployment in K8s: DDS Router as WAN comms enablerROS 2 deployment in K8s: DDS Router as WAN comms enabler
ROS 2 deployment in K8s: DDS Router as WAN comms enabler
 
Seminar Presentation Hadoop
Seminar Presentation HadoopSeminar Presentation Hadoop
Seminar Presentation Hadoop
 
Introduction To RDF and RDFS
Introduction To RDF and RDFSIntroduction To RDF and RDFS
Introduction To RDF and RDFS
 

Similar a Baker Helps Develop Complex APIs

Cross-Project Build Co-change Prediction
Cross-Project Build Co-change PredictionCross-Project Build Co-change Prediction
Cross-Project Build Co-change PredictionShane McIntosh
 
Building an API for EHR integration at scale
Building an API for EHR integration at scaleBuilding an API for EHR integration at scale
Building an API for EHR integration at scaleRedox Engine
 
I Love APIs 2015: Crash Course Foundational Topics in Apigee Edge Workshop
I Love APIs 2015: Crash Course Foundational Topics in Apigee Edge WorkshopI Love APIs 2015: Crash Course Foundational Topics in Apigee Edge Workshop
I Love APIs 2015: Crash Course Foundational Topics in Apigee Edge WorkshopApigee | Google Cloud
 
GraphQL Advanced
GraphQL AdvancedGraphQL Advanced
GraphQL AdvancedLeanIX GmbH
 
wp-25tips-oltscripts-2287467
wp-25tips-oltscripts-2287467wp-25tips-oltscripts-2287467
wp-25tips-oltscripts-2287467Yutaka Takatsu
 
[Webinar] Interacting with BigQuery and Working with Advanced Queries
[Webinar] Interacting with BigQuery and Working with Advanced Queries[Webinar] Interacting with BigQuery and Working with Advanced Queries
[Webinar] Interacting with BigQuery and Working with Advanced QueriesTatvic Analytics
 
Declare, verify and execute microservice process flows with Baker
Declare, verify and execute microservice process flows with BakerDeclare, verify and execute microservice process flows with Baker
Declare, verify and execute microservice process flows with BakerNikola Kasev
 
Colin Bowern - The Not So Scary Side Of Asp.Net – Model View Controller In Th...
Colin Bowern - The Not So Scary Side Of Asp.Net – Model View Controller In Th...Colin Bowern - The Not So Scary Side Of Asp.Net – Model View Controller In Th...
Colin Bowern - The Not So Scary Side Of Asp.Net – Model View Controller In Th...Refresh Events
 
Devops Journey - internet tech startup
Devops Journey - internet tech startupDevops Journey - internet tech startup
Devops Journey - internet tech startupViresh Doshi
 
SPUnite17 Timer Jobs Event Handlers
SPUnite17 Timer Jobs Event HandlersSPUnite17 Timer Jobs Event Handlers
SPUnite17 Timer Jobs Event HandlersNCCOMMS
 
GWT Quick Start
GWT Quick StartGWT Quick Start
GWT Quick StartGuo Albert
 
Baker Talk at Scale By the Bay 2017 in San Francisco
Baker Talk at Scale By the Bay 2017 in San FranciscoBaker Talk at Scale By the Bay 2017 in San Francisco
Baker Talk at Scale By the Bay 2017 in San FranciscoNikola Kasev
 
Generating Predicate Callback Summaries for the Android Framework
Generating Predicate Callback Summaries for the Android FrameworkGenerating Predicate Callback Summaries for the Android Framework
Generating Predicate Callback Summaries for the Android FrameworkMobileSoft
 
Github Copilot vs Amazon CodeWhisperer for Java developers at JCON 2023
Github Copilot vs Amazon CodeWhisperer for Java developers at JCON 2023Github Copilot vs Amazon CodeWhisperer for Java developers at JCON 2023
Github Copilot vs Amazon CodeWhisperer for Java developers at JCON 2023Vadym Kazulkin
 
Modern ASP.NET Webskills
Modern ASP.NET WebskillsModern ASP.NET Webskills
Modern ASP.NET WebskillsCaleb Jenkins
 
Breaking Dependencies Legacy Code - Cork Software Crafters - September 2019
Breaking Dependencies Legacy Code -  Cork Software Crafters - September 2019Breaking Dependencies Legacy Code -  Cork Software Crafters - September 2019
Breaking Dependencies Legacy Code - Cork Software Crafters - September 2019Paulo Clavijo
 
Understanding Layers of Testing
Understanding Layers of TestingUnderstanding Layers of Testing
Understanding Layers of TestingChristopher Rex
 
the grinder testing certification
the grinder testing certificationthe grinder testing certification
the grinder testing certificationVskills
 

Similar a Baker Helps Develop Complex APIs (20)

Cross-Project Build Co-change Prediction
Cross-Project Build Co-change PredictionCross-Project Build Co-change Prediction
Cross-Project Build Co-change Prediction
 
Building an API for EHR integration at scale
Building an API for EHR integration at scaleBuilding an API for EHR integration at scale
Building an API for EHR integration at scale
 
Api design best practice
Api design best practiceApi design best practice
Api design best practice
 
I Love APIs 2015: Crash Course Foundational Topics in Apigee Edge Workshop
I Love APIs 2015: Crash Course Foundational Topics in Apigee Edge WorkshopI Love APIs 2015: Crash Course Foundational Topics in Apigee Edge Workshop
I Love APIs 2015: Crash Course Foundational Topics in Apigee Edge Workshop
 
GraphQL Advanced
GraphQL AdvancedGraphQL Advanced
GraphQL Advanced
 
wp-25tips-oltscripts-2287467
wp-25tips-oltscripts-2287467wp-25tips-oltscripts-2287467
wp-25tips-oltscripts-2287467
 
[Webinar] Interacting with BigQuery and Working with Advanced Queries
[Webinar] Interacting with BigQuery and Working with Advanced Queries[Webinar] Interacting with BigQuery and Working with Advanced Queries
[Webinar] Interacting with BigQuery and Working with Advanced Queries
 
Declare, verify and execute microservice process flows with Baker
Declare, verify and execute microservice process flows with BakerDeclare, verify and execute microservice process flows with Baker
Declare, verify and execute microservice process flows with Baker
 
Colin Bowern - The Not So Scary Side Of Asp.Net – Model View Controller In Th...
Colin Bowern - The Not So Scary Side Of Asp.Net – Model View Controller In Th...Colin Bowern - The Not So Scary Side Of Asp.Net – Model View Controller In Th...
Colin Bowern - The Not So Scary Side Of Asp.Net – Model View Controller In Th...
 
Swift meetup22june2015
Swift meetup22june2015Swift meetup22june2015
Swift meetup22june2015
 
Devops Journey - internet tech startup
Devops Journey - internet tech startupDevops Journey - internet tech startup
Devops Journey - internet tech startup
 
SPUnite17 Timer Jobs Event Handlers
SPUnite17 Timer Jobs Event HandlersSPUnite17 Timer Jobs Event Handlers
SPUnite17 Timer Jobs Event Handlers
 
GWT Quick Start
GWT Quick StartGWT Quick Start
GWT Quick Start
 
Baker Talk at Scale By the Bay 2017 in San Francisco
Baker Talk at Scale By the Bay 2017 in San FranciscoBaker Talk at Scale By the Bay 2017 in San Francisco
Baker Talk at Scale By the Bay 2017 in San Francisco
 
Generating Predicate Callback Summaries for the Android Framework
Generating Predicate Callback Summaries for the Android FrameworkGenerating Predicate Callback Summaries for the Android Framework
Generating Predicate Callback Summaries for the Android Framework
 
Github Copilot vs Amazon CodeWhisperer for Java developers at JCON 2023
Github Copilot vs Amazon CodeWhisperer for Java developers at JCON 2023Github Copilot vs Amazon CodeWhisperer for Java developers at JCON 2023
Github Copilot vs Amazon CodeWhisperer for Java developers at JCON 2023
 
Modern ASP.NET Webskills
Modern ASP.NET WebskillsModern ASP.NET Webskills
Modern ASP.NET Webskills
 
Breaking Dependencies Legacy Code - Cork Software Crafters - September 2019
Breaking Dependencies Legacy Code -  Cork Software Crafters - September 2019Breaking Dependencies Legacy Code -  Cork Software Crafters - September 2019
Breaking Dependencies Legacy Code - Cork Software Crafters - September 2019
 
Understanding Layers of Testing
Understanding Layers of TestingUnderstanding Layers of Testing
Understanding Layers of Testing
 
the grinder testing certification
the grinder testing certificationthe grinder testing certification
the grinder testing certification
 

Último

Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
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
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
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
 
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
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
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
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
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
 
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
 

Último (20)

Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
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...
 
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
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
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
 
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...
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
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...
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
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
 
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
 

Baker Helps Develop Complex APIs

  • 1. Bekir Oguz Merlijn van Ittersum Designing process flows with #Baker Amsterdam.Scala Meetup September 2017
  • 2. How to bake a pizza? 2
  • 3. How to bake a pizza? 3
  • 4. How to bake a pizza? 4
  • 6. It is hard to develop complex orchestration APIs 6
  • 7. 7
  • 8. We need a cleaner way to allow design changes in complex APIs 8 Example: initial design of the API A B C D E 1 2 3 4 5
  • 9. A B C D E 1 2 3 4 5 We need a cleaner way to allow design changes in complex APIs 9 Example: API after one design change
  • 10. A B C D E 1 2 3 4 5 We need a cleaner way to allow design changes in complex APIs 10 Example: API after ten design changes
  • 11. We need a cleaner way to allow design changes in complex APIs 11 Example: API after ten design changes A B C D E 1 2 3 4 5
  • 12. Open Kinder- / Jongerenrekening Open Groei Groter rekening Another Product Verify customer rules Verify customer rules Verify customer rules Register individual Register individual Register Individual Send a present Send a present Not applicable Send a message to the customer Send a message to the customer Send a message to the customer Open a payments account Open a savings account Open a payments account Enable billing Enable billing Assign package There is more need for reuse between teams 12
  • 14. Baker is a Scala library that simplifies the development of complex orchestration logic. What? Baker! github.com/ing-bank/baker
  • 17. Defining ingredients 17 case class CustomerInfo(name: String, address: String, email: String) // ingredients val customerInfo = Ingredient[CustomerInfo]("customerInfo") val trackingId = Ingredient[String]("trackingId") val order = Ingredient[String]("order")
  • 18. Defining events 18 // events val goodsShipped = Event("GoodsShipped", trackingId) val orderPlaced = Event("OrderPlaced", order) val paymentMade = Event("PaymentMade") val valid = Event("Valid") val sorry = Event("Sorry")
  • 19. Defining interactions 19 // interactions val validateOrder = Interaction( name = "ValidateOrder", inputIngredients = order, output = FiresOneOfEvents(valid, sorry) ) val shipGoods = Interaction( name = "ShipGoods", inputIngredients = Ingredients(goods, customerInfo), output = FiresOneOfEvents(goodsShipped) )
  • 20. Defining a recipe 20 // recipe val webShopRecipe: Recipe = Recipe("WebShop") .withInteractions( validateOrder, manufactureGoods .withRequiredEvents(valid, paymentMade), shipGoods, sendInvoice .withRequiredEvent(goodsShipped) ) .withSensoryEvents( customerInfoReceived, orderPlaced, paymentMade)
  • 21. Compile the recipe 21 // compiles the recipe val compiledRecipe = RecipeCompiler.compileRecipe(webShopRecipe) // list of validation errors val errors: Seq[String] = compiledRecipe.validationErrors // .dot (graphviz notation) representation val visualization: String = compiledRecipe.getRecipeVisualization
  • 23. A Baker instance can be created from the valid recipe. It takes care of the execution of the recipe. The only thing left is to provide sensory events to Baker! Baker runtime 23
  • 24. Initializing Baker instance 24 You can create a new Baker instance by providing the recipe and implementations of the interactions: val compiledRecipe = RecipeCompiler.compileRecipe(webShopRecipe) val validateOrderImpl = validateOrder implement { (order: String) => { // Some logic here valid.instance() // or maybe invalid event to be returned } } val implementations = Seq(validateOrderImpl, manufactureGoodsImpl, sendInvoiceImpl, shipGoodsImpl) val baker = new Baker(compiledRecipe, implementations)
  • 25. For each client request you do the following: Firing events 25 val processId = UUID.randomUUID().toString baker.bake(processId) baker.handleEvent(processId, orderPlaced.instance(testOrder)) baker.handleEvent(processId, paymentMade.instance()) baker.handleEvent(processId, customerInfoReceived.instance(testCustomerInfoData)) val actualIngredients: Map[String, Any] = baker.getIngredients(processId) val actualEvents: Seq[RuntimeEvent] = baker.events(processId)
  • 26. 26
  • 27. 27
  • 28. 28
  • 29. 29
  • 30. 30
  • 31. 31
  • 32. 32
  • 33. 33
  • 34. 34
  • 35. 35
  • 36. 36
  • 37. 37
  • 38. 38
  • 39. 39
  • 40. 40
  • 41. 41
  • 42. 1. It is hard to develop complex orchestration APIs 2. We need a cleaner way to allow design changes in complex APIs 3. There is more need for reuse between teams Does Baker help with the Why? 42
  • 43. 1. It is hard to develop complex orchestration APIs With Baker, you think about what you want, not about the order. Baker can validate the recipe for you. Clear insight in the current model by visualising the recipe. 2. We need a cleaner way to allow design changes in complex APIs 3. There is more need for reuse between teams Does Baker help with the Why? 43
  • 44. 1. It is hard to develop complex orchestration APIs With Baker, you think about what you want, not about the order. Baker can validate the recipe for you. Clear insight in the current model by visualising the recipe. 2. We need a cleaner way to allow design changes in complex APIs Baker links the interactions when compiling the recipe. If interactions are added, removed or changed, Baker will update the model accordingly. 3. There is more need for reuse between teams Does Baker help with the Why? 44
  • 45. 1. It is hard to develop complex orchestration APIs With Baker, you think about what you want, not about the order. Baker can validate the recipe for you. Clear insight in the current model by visualising the recipe. 2. We need a cleaner way to allow design changes in complex APIs Baker links the interactions when compiling the recipe. If interactions are added, removed or changed, Baker will update the model accordingly. 3. There is more need for reuse between teams The possibility to share interactions, ingredients and events between recipes allows for much more reuse of code among teams. Does Baker help with the Why? 45
  • 46. How?
  • 47. Baker is powered by 47 PetriNet
  • 48. Process logic is isolated in an Akka actor, this gives us the following benefits: • Event sourcing through persistent actors • Supporting many data stores, i.e. cassandra • Distributing actors with Cluster Sharding Akka 48
  • 49. On creation of the Baker instance, the recipe is compiled into a Petri net. A Petri net is a mathematical model that can be used for reasoning about concurrency. This Petri net is then used to determine when & what interactions to execute. PetriNet 49
  • 50. Execution Semantics: Token passing 50 t1 t2 t3
  • 51. Execution Semantics: Token passing 51 t1 t2 t3
  • 52. Execution Semantics: Token passing 52 t1 t2 t3
  • 53. Execution Semantics: Token passing 53 t1 t2 t3
  • 60. • Simple, uses only a few concepts and components • Exact mathematical definition of execution semantics • Intuitive graphical notation • Well-developed mathematical theory for process analysis Advantages 60
  • 64. Path traversal time 64 Average traversal time: 10 seconds A B
  • 69. 69 Features Recipe Developer friendly Java/Scala dsl Compile-time recipe validation Runtime
  • 70. 70 Features Recipe Developer friendly Java/Scala dsl Compile-time recipe validation Type safety Runtime
  • 71. 71 Features Recipe Developer friendly Java/Scala dsl Compile-time recipe validation Type safety Runtime Execution of the recipe, powered by akka and petrinet model
  • 72. 72 Features Recipe Developer friendly Java/Scala dsl Compile-time recipe validation Type safety Runtime Execution of the recipe, powered by akka and petrinet model Persisted state through event sourcing
  • 73. 73 Features Recipe Developer friendly Java/Scala dsl Compile-time recipe validation Type safety Runtime Execution of the recipe, powered by akka and petrinet model Persisted state through event sourcing Data encryption
  • 74. 74 Features Recipe Developer friendly Java/Scala dsl Compile-time recipe validation Type safety Runtime Execution of the recipe, powered by akka and petrinet model Persisted state through event sourcing Data encryption Automatic retries on technical failures
  • 75. 75 Features Recipe Developer friendly Java/Scala dsl Compile-time recipe validation Type safety Runtime Execution of the recipe, powered by akka and petrinet model Persisted state through event sourcing Data encryption Automatic retries on technical failures Parallel execution of paths
  • 77. Property Based Testing 77 val recipeGen: Gen[Recipe] = for { name <- nameGen sensoryEvents <- Gen.listOf(eventGen) suchThat (_.nonEmpty) interactions <- interactionsGen(sensoryEvents) suchThat (_.nonEmpty) } yield Recipe(name) //turn the lists into var args .withSensoryEvents(sensoryEvents: _*) .withInteractions(interactions.toList: _*)
  • 78. Property Based Testing 78 forAll(recipeGen) { recipe => val validations = ValidationSettings( allowCycles = false, allowNonExecutableInteractions = false) val compiledRecipe = RecipeCompiler.compileRecipe(recipe, validations) if (compiledRecipe.validationErrors.nonEmpty) { logRecipeStats(recipe) logCompiledRecipeStats(compiledRecipe) } compiledRecipe.validationErrors.isEmpty }

Notas del editor

  1. Interactions are reusable across multiple teams/processes/recipes
  2. Interactions are reusable across multiple teams/processes/recipes
  3. API doesn’t know about the order, just fires events
  4. Transition -> Blue Places -> Orange Token -> Black dot
  5. Hash collision problem found