SlideShare une entreprise Scribd logo
1  sur  39
Take Flight : Fly Object Space

Nigel.Warren@underscoreconsulting.com
Themes
• Spaces
• Fly Object Space
• Flight
• Fly and Play Demo
• Roundup

https://github.com/fly-object-space google : Fly Object Space
Spaces
Tuple Spaces – Linda - a co-ordination language
Presents a boundary for signals between …
Threads - Processes – Machines - Systems
Minimal Interface
3 Essential Operations
Timely – Lease based
Immutable Only
Fly
Operations
op
op
op

write(entry, lease ): lease
read(template, lease): Option[entry]
take(template, lease): Option[entry]

Query By Template
Template

Entry

Car(Some("Red"), None) == Car(Some("Red"), Some(5))
Car(None, Some(7))

!= Car(Some("Red"), Some(5))

Car(None, None)

== Car(Some("Red"), Some(2))
Write Op
def write(entry: AnyRef, lease: Long) : Long
Read Op
def read[T<: AnyRef](template: T, lease: Long): Option[T]
Take Op
def take[T<: AnyRef](template: T, lease: Long): Option[T]
Time Passes
Leases Expire
Design Diamond
Minimise Interface

Complexity

Minimise Uses
Flight
Idea : Advances in core Scala libraries can be applied to Fly
Futures
Ops are time constrained
Ops may succeed or fail
FiniteDurations
Express only finite leases in nanos (prev millis)
Make a JVM local ( inter-thread ) version that has the new
features as a test bed.
Flight
Experimental

Image : Experimental Aircarft - Woolf Sverak – www.redbubble.com
Flight
write[T <: AnyRef](entry: T, lease: FiniteDuration) :
Future[FiniteDuration] = …
read[T <: AnyRef](template: T, lease: FiniteDuration) :
Future[T] = …
take[T <: AnyRef](template: T, lease: FiniteDuration) :
Future[T] = …
Flight – Example
import
import
import
import

scala.concurrent.ExecutionContext.Implicits.global
scala.concurrent._
scala.concurrent.duration._
scala.language.postfixOps

import com.zink.fly.{ Flight => flt }
import com.zink.fly.examples.Price

//case class Price(symbol: Option[String], value: Option[Int])
Flight – Example

val offer = Price(Some("ARM"),Some(123))

flt.write(offer, 100 seconds) onSuccess {
case lease => println(s"Offer written for $lease")
}
"Offer written for 100 seconds"
Flight – Example
val tmpl = Price(Some("ARM"), None)

flt.read(tmpl, 10 seconds) onComplete {
case Success(entry) => println(entry)
case Failure(t) => println("Sorry: " + t.getMessage)
}
flt.take(tmpl, 10 seconds) onSuccess {
case ent => println(s"Take matched $ent")
}
Flight – Prop
val tmplArm = Price(Some("ARM"),Some(123))
val tmplWlf = Price(Some("WLF"),Some(321))
val lse = 10 seconds
val futArm = flt.read(tmplArm, lse)
val futWlf = flt.read(tmplWlf, lse)
(futArm zip futWlf) onComplete {
case Success(e) => println("Deal")
case Failure(t) => println("No Deal")
}
Fly – Demo
Fly – Summary
• Timely Distributed Computing
• Core Scala Library only
• Work with everything else
• Flight (Experimental) Interface
• FiniteDurations
• Futures
https://github.com/fly-object-space google : Fly Object Space
>
<------------>
<--->

Thanks
www.flyobjectspace.com
www.twitter.com/flyobjectspace
Playing with Fly
Asher Glynn
asher.glynn@burrowingdeep.com
Overview




Used Play 2.0 framework last year for startup
Simple as possible – database and app servers
Adapted to leverage Fly
Starting out with play


My journey






Copy an example
Write logic in Action handlers
Write DAO layer
Discover you need an API
Rewrite with quite a lot of swearing
Abstracting the logic
def Story[Request, Response](request: Request)
(logic: Connection => Response)
(implicit
validators: Seq[Request => Connection =>
Option[StoryError]],
reactors: Request => Response =>
Seq[Notification]) : Either[StoryError, Response]
= {
… // Handle transaction
}
Notes on Story abstraction






Use request/response to (potentially) allow for Akka
distribution
Handles overall transaction
Validators execute sequentially prior to logic
Reactor executes afterwards and asynchronously writes
notifications (if any) outside transaction context
Might have gone too far with implicits
Notifications – with DB






Put an adapter in but never did anything with them
Inserting into DB easy
Querying reasonably painful
NoSQL + Message Bus non trivial + complex in fast
moving startup
Eventually disabled clients
Notifications - With Fly





Easy filters
Get notifications without polling with notifyWrite
Can listen for interesting notifications out
Trivial to implement via writeMany
Closing auctions





Auction system needs once only transaction
Late auction is a bad one (unlikely to replay in case of
long outage)
Only winning bids translate to transactions
All nodes capable of closing transaction (for redundancy)
Closing auction - database


Various options – easiest holding write lock through a
select for update

def pin(auctionId: UUID) = SQL ("Select * from
TA_LOCKS where LOCKABLE = 'CLOSER' FOR
UPDATE").execute





Locks out other nodes
Could be finer grained
Needs to have extra timeout code setup to execute
predictably
Only once by virtue of changed state in DB (need to
check)
Closing auction - Fly


Contrast in Fly

fly.take(new models.auction.Auction(id = auctionId),
1000L)



Timeouts “for free”
Only once by virtue of getting the take
Integrating Fly




Upgrade to current version of Play
Add fly-java lib to /lib folder
Add to dependencies in Build.sbt

"com.flyobjectspace" %% "flyscala" % "2.1.0SNAPSHOT”


And you are away
Modifications for Fly


Modify constructor of class for null fields

case class Auction (
id
: UUID = null,
accountId
: UUID = null,


Add trait to indicate well formedness

trait WellFormed {
def isWellFormed : Boolean
}
Modifications for Fly


And add check for WellFormedness to each story



Add to validation chain
Add to main part of story



Use notifications to invalidate cache



Write auctions to Fly, use take for once only
Mistakes integrating with Fly





Going nuts with Akka
Messing up lease times and objects disappearing
Lease time too short
Adding 2PC complexity to thinking rather than working
within the Fly idiom
Running out of talent…




Use either presence of object in Space to indicate lock –
or absence!
For Auction – absence of auction object
For Account modifications – presence of object




What if there are two
What if the owner disappears
What if the ownership changes on an edge (split brain)
Longer term modifications






Modify Story abstraction to work with Futures
Modify to work cleanly with account balances
Keep database but redesign to work nicely with Fly
Keep notifications out of database
Flatten notification structure
Final note on notifications


Currently using a deep class

case class Notice( id: UUID,
originatorId: UUID,
timestamp: Long,
attributes: Map[String, String],
to: Seq[UUID],
system: Boolean)


Will flatten to help leverage Fly filters

case class Notice (subject: String = null,
_predicate: String = null,
_object = String)

And correlate on receivers
Thanks

Contenu connexe

Tendances

Connecting C++ and JavaScript on the Web with Embind
Connecting C++ and JavaScript on the Web with EmbindConnecting C++ and JavaScript on the Web with Embind
Connecting C++ and JavaScript on the Web with Embind
Chad Austin
 

Tendances (20)

iOS App Development with F# and Xamarin
iOS App Development with F# and XamariniOS App Development with F# and Xamarin
iOS App Development with F# and Xamarin
 
Gotchas using Terraform in a secure delivery pipeline
Gotchas using Terraform in a secure delivery pipelineGotchas using Terraform in a secure delivery pipeline
Gotchas using Terraform in a secure delivery pipeline
 
Terraform -- Infrastructure as Code
Terraform -- Infrastructure as CodeTerraform -- Infrastructure as Code
Terraform -- Infrastructure as Code
 
Building infrastructure as code using Terraform - DevOps Krakow
Building infrastructure as code using Terraform - DevOps KrakowBuilding infrastructure as code using Terraform - DevOps Krakow
Building infrastructure as code using Terraform - DevOps Krakow
 
What you see is what you get for AWS infrastructure
What you see is what you get for AWS infrastructureWhat you see is what you get for AWS infrastructure
What you see is what you get for AWS infrastructure
 
Terraform AWS modules and some best-practices - May 2019
Terraform AWS modules and some best-practices - May 2019Terraform AWS modules and some best-practices - May 2019
Terraform AWS modules and some best-practices - May 2019
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot Camp
 
Csp scala wixmeetup2016
Csp scala wixmeetup2016Csp scala wixmeetup2016
Csp scala wixmeetup2016
 
Squeezing Machine Learning into Serverless for Image Recognition - AWS Meetup...
Squeezing Machine Learning into Serverless for Image Recognition - AWS Meetup...Squeezing Machine Learning into Serverless for Image Recognition - AWS Meetup...
Squeezing Machine Learning into Serverless for Image Recognition - AWS Meetup...
 
Infrastructure as Code: Introduction to Terraform
Infrastructure as Code: Introduction to TerraformInfrastructure as Code: Introduction to Terraform
Infrastructure as Code: Introduction to Terraform
 
Infrastructure as Code with Terraform
Infrastructure as Code with TerraformInfrastructure as Code with Terraform
Infrastructure as Code with Terraform
 
Scaling terraform
Scaling terraformScaling terraform
Scaling terraform
 
Presentation kyushu-2018
Presentation kyushu-2018Presentation kyushu-2018
Presentation kyushu-2018
 
Connecting C++ and JavaScript on the Web with Embind
Connecting C++ and JavaScript on the Web with EmbindConnecting C++ and JavaScript on the Web with Embind
Connecting C++ and JavaScript on the Web with Embind
 
EuroPython 2017 - Bonono - Simple ETL in python 3.5+
EuroPython 2017 - Bonono - Simple ETL in python 3.5+EuroPython 2017 - Bonono - Simple ETL in python 3.5+
EuroPython 2017 - Bonono - Simple ETL in python 3.5+
 
Swift Cloud Workshop - Swift Microservices
Swift Cloud Workshop - Swift MicroservicesSwift Cloud Workshop - Swift Microservices
Swift Cloud Workshop - Swift Microservices
 
Shelly cloud & heroku & engineyard. Pros & Cons
Shelly cloud & heroku & engineyard. Pros & ConsShelly cloud & heroku & engineyard. Pros & Cons
Shelly cloud & heroku & engineyard. Pros & Cons
 
Fast C++ Web Servers
Fast C++ Web ServersFast C++ Web Servers
Fast C++ Web Servers
 
Simple ETL in python 3.5+ with Bonobo - PyParis 2017
Simple ETL in python 3.5+ with Bonobo - PyParis 2017Simple ETL in python 3.5+ with Bonobo - PyParis 2017
Simple ETL in python 3.5+ with Bonobo - PyParis 2017
 
Cypher for Gremlin
Cypher for GremlinCypher for Gremlin
Cypher for Gremlin
 

Similaire à Take Flight - Using Fly with the Play Framework

Exploring SharePoint with F#
Exploring SharePoint with F#Exploring SharePoint with F#
Exploring SharePoint with F#
Talbott Crowell
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
David Padbury
 
Dev Day 2019: Mike Sperber – Software Design für die Seele
Dev Day 2019: Mike Sperber – Software Design für die SeeleDev Day 2019: Mike Sperber – Software Design für die Seele
Dev Day 2019: Mike Sperber – Software Design für die Seele
DevDay Dresden
 
JavaScript (without DOM)
JavaScript (without DOM)JavaScript (without DOM)
JavaScript (without DOM)
Piyush Katariya
 
Effective Scala (JavaDay Riga 2013)
Effective Scala (JavaDay Riga 2013)Effective Scala (JavaDay Riga 2013)
Effective Scala (JavaDay Riga 2013)
mircodotta
 

Similaire à Take Flight - Using Fly with the Play Framework (20)

Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojure
 
Porting Java To Scala
Porting Java To Scala Porting Java To Scala
Porting Java To Scala
 
Exploring SharePoint with F#
Exploring SharePoint with F#Exploring SharePoint with F#
Exploring SharePoint with F#
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
Node.js - Advanced Basics
Node.js - Advanced BasicsNode.js - Advanced Basics
Node.js - Advanced Basics
 
Go 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX GoGo 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX Go
 
Exploring Clojurescript
Exploring ClojurescriptExploring Clojurescript
Exploring Clojurescript
 
ITB2019 Real World Scenarios for Modern CFML - Nolan Erck
ITB2019 Real World Scenarios for Modern CFML - Nolan ErckITB2019 Real World Scenarios for Modern CFML - Nolan Erck
ITB2019 Real World Scenarios for Modern CFML - Nolan Erck
 
Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
 
Dev Day 2019: Mike Sperber – Software Design für die Seele
Dev Day 2019: Mike Sperber – Software Design für die SeeleDev Day 2019: Mike Sperber – Software Design für die Seele
Dev Day 2019: Mike Sperber – Software Design für die Seele
 
Things about Functional JavaScript
Things about Functional JavaScriptThings about Functional JavaScript
Things about Functional JavaScript
 
Clojure made-simple - John Stevenson
Clojure made-simple - John StevensonClojure made-simple - John Stevenson
Clojure made-simple - John Stevenson
 
JavaScript (without DOM)
JavaScript (without DOM)JavaScript (without DOM)
JavaScript (without DOM)
 
Echtzeitapplikationen mit Elixir und GraphQL
Echtzeitapplikationen mit Elixir und GraphQLEchtzeitapplikationen mit Elixir und GraphQL
Echtzeitapplikationen mit Elixir und GraphQL
 
Scala is java8.next()
Scala is java8.next()Scala is java8.next()
Scala is java8.next()
 
Data Pipeline at Tapad
Data Pipeline at TapadData Pipeline at Tapad
Data Pipeline at Tapad
 
Effective Scala (JavaDay Riga 2013)
Effective Scala (JavaDay Riga 2013)Effective Scala (JavaDay Riga 2013)
Effective Scala (JavaDay Riga 2013)
 
Cloud meets Fog & Puppet A Story of Version Controlled Infrastructure
Cloud meets Fog & Puppet A Story of Version Controlled InfrastructureCloud meets Fog & Puppet A Story of Version Controlled Infrastructure
Cloud meets Fog & Puppet A Story of Version Controlled Infrastructure
 
Concurrency Constructs Overview
Concurrency Constructs OverviewConcurrency Constructs Overview
Concurrency Constructs Overview
 

Dernier

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

Take Flight - Using Fly with the Play Framework

  • 1. Take Flight : Fly Object Space Nigel.Warren@underscoreconsulting.com
  • 2. Themes • Spaces • Fly Object Space • Flight • Fly and Play Demo • Roundup https://github.com/fly-object-space google : Fly Object Space
  • 3. Spaces Tuple Spaces – Linda - a co-ordination language Presents a boundary for signals between … Threads - Processes – Machines - Systems Minimal Interface 3 Essential Operations Timely – Lease based Immutable Only
  • 4. Fly Operations op op op write(entry, lease ): lease read(template, lease): Option[entry] take(template, lease): Option[entry] Query By Template Template Entry Car(Some("Red"), None) == Car(Some("Red"), Some(5)) Car(None, Some(7)) != Car(Some("Red"), Some(5)) Car(None, None) == Car(Some("Red"), Some(2))
  • 5. Write Op def write(entry: AnyRef, lease: Long) : Long
  • 6. Read Op def read[T<: AnyRef](template: T, lease: Long): Option[T]
  • 7. Take Op def take[T<: AnyRef](template: T, lease: Long): Option[T]
  • 10.
  • 11.
  • 12. Flight Idea : Advances in core Scala libraries can be applied to Fly Futures Ops are time constrained Ops may succeed or fail FiniteDurations Express only finite leases in nanos (prev millis) Make a JVM local ( inter-thread ) version that has the new features as a test bed.
  • 13. Flight Experimental Image : Experimental Aircarft - Woolf Sverak – www.redbubble.com
  • 14. Flight write[T <: AnyRef](entry: T, lease: FiniteDuration) : Future[FiniteDuration] = … read[T <: AnyRef](template: T, lease: FiniteDuration) : Future[T] = … take[T <: AnyRef](template: T, lease: FiniteDuration) : Future[T] = …
  • 15. Flight – Example import import import import scala.concurrent.ExecutionContext.Implicits.global scala.concurrent._ scala.concurrent.duration._ scala.language.postfixOps import com.zink.fly.{ Flight => flt } import com.zink.fly.examples.Price //case class Price(symbol: Option[String], value: Option[Int])
  • 16. Flight – Example val offer = Price(Some("ARM"),Some(123)) flt.write(offer, 100 seconds) onSuccess { case lease => println(s"Offer written for $lease") } "Offer written for 100 seconds"
  • 17. Flight – Example val tmpl = Price(Some("ARM"), None) flt.read(tmpl, 10 seconds) onComplete { case Success(entry) => println(entry) case Failure(t) => println("Sorry: " + t.getMessage) } flt.take(tmpl, 10 seconds) onSuccess { case ent => println(s"Take matched $ent") }
  • 18. Flight – Prop val tmplArm = Price(Some("ARM"),Some(123)) val tmplWlf = Price(Some("WLF"),Some(321)) val lse = 10 seconds val futArm = flt.read(tmplArm, lse) val futWlf = flt.read(tmplWlf, lse) (futArm zip futWlf) onComplete { case Success(e) => println("Deal") case Failure(t) => println("No Deal") }
  • 20. Fly – Summary • Timely Distributed Computing • Core Scala Library only • Work with everything else • Flight (Experimental) Interface • FiniteDurations • Futures https://github.com/fly-object-space google : Fly Object Space
  • 22. Playing with Fly Asher Glynn asher.glynn@burrowingdeep.com
  • 23. Overview    Used Play 2.0 framework last year for startup Simple as possible – database and app servers Adapted to leverage Fly
  • 24. Starting out with play  My journey      Copy an example Write logic in Action handlers Write DAO layer Discover you need an API Rewrite with quite a lot of swearing
  • 25. Abstracting the logic def Story[Request, Response](request: Request) (logic: Connection => Response) (implicit validators: Seq[Request => Connection => Option[StoryError]], reactors: Request => Response => Seq[Notification]) : Either[StoryError, Response] = { … // Handle transaction }
  • 26. Notes on Story abstraction      Use request/response to (potentially) allow for Akka distribution Handles overall transaction Validators execute sequentially prior to logic Reactor executes afterwards and asynchronously writes notifications (if any) outside transaction context Might have gone too far with implicits
  • 27. Notifications – with DB      Put an adapter in but never did anything with them Inserting into DB easy Querying reasonably painful NoSQL + Message Bus non trivial + complex in fast moving startup Eventually disabled clients
  • 28. Notifications - With Fly     Easy filters Get notifications without polling with notifyWrite Can listen for interesting notifications out Trivial to implement via writeMany
  • 29. Closing auctions     Auction system needs once only transaction Late auction is a bad one (unlikely to replay in case of long outage) Only winning bids translate to transactions All nodes capable of closing transaction (for redundancy)
  • 30. Closing auction - database  Various options – easiest holding write lock through a select for update def pin(auctionId: UUID) = SQL ("Select * from TA_LOCKS where LOCKABLE = 'CLOSER' FOR UPDATE").execute     Locks out other nodes Could be finer grained Needs to have extra timeout code setup to execute predictably Only once by virtue of changed state in DB (need to check)
  • 31. Closing auction - Fly  Contrast in Fly fly.take(new models.auction.Auction(id = auctionId), 1000L)   Timeouts “for free” Only once by virtue of getting the take
  • 32. Integrating Fly    Upgrade to current version of Play Add fly-java lib to /lib folder Add to dependencies in Build.sbt "com.flyobjectspace" %% "flyscala" % "2.1.0SNAPSHOT”  And you are away
  • 33. Modifications for Fly  Modify constructor of class for null fields case class Auction ( id : UUID = null, accountId : UUID = null,  Add trait to indicate well formedness trait WellFormed { def isWellFormed : Boolean }
  • 34. Modifications for Fly  And add check for WellFormedness to each story   Add to validation chain Add to main part of story  Use notifications to invalidate cache  Write auctions to Fly, use take for once only
  • 35. Mistakes integrating with Fly     Going nuts with Akka Messing up lease times and objects disappearing Lease time too short Adding 2PC complexity to thinking rather than working within the Fly idiom
  • 36. Running out of talent…    Use either presence of object in Space to indicate lock – or absence! For Auction – absence of auction object For Account modifications – presence of object    What if there are two What if the owner disappears What if the ownership changes on an edge (split brain)
  • 37. Longer term modifications      Modify Story abstraction to work with Futures Modify to work cleanly with account balances Keep database but redesign to work nicely with Fly Keep notifications out of database Flatten notification structure
  • 38. Final note on notifications  Currently using a deep class case class Notice( id: UUID, originatorId: UUID, timestamp: Long, attributes: Map[String, String], to: Seq[UUID], system: Boolean)  Will flatten to help leverage Fly filters case class Notice (subject: String = null, _predicate: String = null, _object = String) And correlate on receivers

Notes de l'éditeur

  1. John Holland&apos;s – Signals and Boundarys