SlideShare uma empresa 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?

Mais conteúdo relacionado

Semelhante a Designing process flows with #Baker

wp-25tips-oltscripts-2287467
wp-25tips-oltscripts-2287467wp-25tips-oltscripts-2287467
wp-25tips-oltscripts-2287467
Yutaka Takatsu
 
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
 
GWT Quick Start
GWT Quick StartGWT Quick Start
GWT Quick Start
Guo Albert
 

Semelhante a Designing process flows with #Baker (20)

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
 
26 story slicing techniques for any scrum team
26 story slicing techniques for any scrum team26 story slicing techniques for any scrum team
26 story slicing techniques for any scrum team
 
Accelerate Your Delivery Pipeline with Continuous Testing
Accelerate Your Delivery Pipeline with Continuous TestingAccelerate Your Delivery Pipeline with Continuous Testing
Accelerate Your Delivery Pipeline with Continuous Testing
 
@avanttic_meetup Oracle Technology MAD_BCN: Oracle Cloud API Platform evoluc...
@avanttic_meetup Oracle Technology MAD_BCN:  Oracle Cloud API Platform evoluc...@avanttic_meetup Oracle Technology MAD_BCN:  Oracle Cloud API Platform evoluc...
@avanttic_meetup Oracle Technology MAD_BCN: Oracle Cloud API Platform evoluc...
 
Acercándonos a la Programación Funcional a través de la Arquitectura Hexag...
Acercándonos a la Programación Funcional a través de la Arquitectura Hexag...Acercándonos a la Programación Funcional a través de la Arquitectura Hexag...
Acercándonos a la Programación Funcional a través de la Arquitectura Hexag...
 

Último

Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 

Último (20)

Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 

Designing process flows with #Baker

  • 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 do 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