enterprise rest a case study
play

enterprise REST a case study twitter:@BrandonByars the eight - PowerPoint PPT Presentation

enterprise REST a case study twitter:@BrandonByars the eight fallacies of distributed programming the network is reliable topology doesnt change latency is zero there is one administrator bandwidth is infinite


  1. enterprise REST a case study twitter:@BrandonByars �

  2. the eight fallacies of distributed programming • the network is reliable • topology doesn’t change • latency is zero • there is one administrator • bandwidth is infinite • transport cost is zero • the network is secure • the network is homogenous

  3. Forcing people to use HATEOA your links � S Standard HTTP Interface � URI Resources � POX RPC / SOAP �

  4. HATEOA S Most REST mistakes HTTP happen over here… � versioning URI deployment testing POX service granularity

  5. REST

  6. a story about a billing system...

  7. a story about a legacy rewrite...

  8. dramatis personae

  9. field ¡force ¡ inventory: ¡ CSR ¡ management ¡ telephony ¡ UI ¡ order ¡ management ¡ order ¡ provisioning ¡ dramatis entry ¡ personae product ¡ inventory: ¡ catalog ¡ physical ¡ customer ¡ billing ¡ Web ¡ address ¡

  10. Choreography... ...not orchestration

  11. define logical environments for isolation

  12. Shared Integration VM � Bob’s Workstation � Order � C1 � Customer � O1 � Mary’s Workstation � P1 � Product � Order � O1 �

  13. Shared Integration VM � Bob’s Workstation � P1 � Product � Order � C1 � Customer � O1 � Mary’s Workstation � P2 � Product � Order � C2 � Customer � O1 �

  14. Shared Integration VM � Bob’s Workstation � P1 � Product � Order � C1 � Customer � O1 � Mary’s Workstation � P2 � Product � Order � C2 � Customer � O1 �

  15. Bob’s Environment � Shared Integration VM � Bob’s Workstation � P1 � Product � Order � C1 � Customer � O1 � Mary’s Workstation � P2 � Product � Order � C2 � Customer � O1 � Mary’s Environment �

  16. coordinated deployments

  17. order-bob: � product: � webServers: [s1.test.dev] �� url: http://s1.test.dev: 8000 /products � dbServer: s1.test.dev � dbName: OrderBobProducts � customer: � webServers: [s1.test.dev] � url: http://s1.test.dev: 8001 /customers � dbServer: s1.test.dev � dbName: OrderBobCustomers � � order-mary: � product: � webServers: [s1.test.dev] � url: http://s1.test.dev: 8002 /products �

  18. order-bob: � product: � webServers: [s1.test.dev] �� url: http://s1.test.dev: 8000 /products � dbServer: s1.test.dev � dbName: OrderBobProducts � customer: � webServers: [s1.test.dev] � url: http://s1.test.dev: 8001 /customers � dbServer: s1.test.dev � dbName: OrderBobCustomers � � order-mary: � product: � webServers: [s1.test.dev] � url: http://s1.test.dev: 8002 /products �

  19. version as a last resort

  20. UI � 4.1.1 � Order Billing � Entry � 5.13.3 � Product �

  21. speling mistaeks { � { � "customer": { � "customer": { � "firstName": "Fred", � "firstName": "Fred", � "LastName": "Flinstone" � " lastName ": "Flinstone" � } � } � } � } �

  22. Postel’s Law @RequestMapping(method=POST, produces=application/json) � @ResponseBody � public OrderResource createOrder( � � @RequestBody Order order, � � HttpServletResponse response � ) throws OrderException � { � � ... � � ... � } �

  23. separate functional testing from integration testing

  24. deployment pipeline Commit � Automated � Showcase � SIT � Pre-prod � Production � Tests � 3.1.12 � 3.1.11 � 3.1.3 � 3.0.6 � 3.0.6 � 2.16.1 �

  25. deployment pipelines... Isolated SIT � Pre-prod � Production � Pipelines � 3.1.3 � 3.0.6 � 3.0.6 � 2.16.1 � Order Entry � 4.2.3 � 4.2.0 � 4.1.2 � 4.1.1 � Billing � 7.2.6 � Product � 7.2.0 � 7.2.0 � 7.2.0 � 2.2.5 � 2.2.0 � UI � 2.2.0 � 2.1.33 �

  26. early stages Commit � Isolation … � … � … � … � Tests � 3.1.12 � 3.1.11 � 3.1.3 � 3.0.6 � 3.0.6 � 2.16.1 � stub ruthlessly

  27. hand-crafted stubs System Stub Under Server � Test � Tests �

  28. record and replay stubs System Stub Real � Under Server � Dependency � Test � Tests �

  29. general purpose stubs System Stub Under Server � Test � Stub � Setup � Tests �

  30. Moco : https://github.com/dreamhead/moco � vcr : https://github.com/vcr/vcr � � β etamax : https://github.com/robfletcher/betamax � � stubby4j : https://github.com/azagniotov/stubby4j � � � mountebank : http://www.mbtest.org/ �

  31. early stages Commit � Isolation … � … � … � … � Tests � 3.1.12 � 3.1.11 � 3.1.3 � 3.0.6 � 3.0.6 � 2.16.1 �

  32. early stages Contract Commit � Isolation … � … � … � … � Tests � Tests � 3.1.12 � 3.1.11 � 3.1.3 � 3.0.6 � 3.0.6 � 2.16.1 �

  33. Isolated Contract � Pre-prod � Production � Pipelines � Tests � 3.1.3 � 3.0.6 � 3.0.6 � 2.16.1 � Order Entry � 4.2.3 � 4.2.0 � 4.1.2 � 4.1.1 � Billing � 7.2.6 � Product � 7.2.0 � 7.2.0 � 7.2.0 � 2.2.5 � 2.2.0 � 2.2.0 � UI � 2.1.33 �

  34. Isolated Contract � Artifacts � Pipelines � Tests � 3.1.3 � 3.1.2 � Order Entry � Tests � 4.2.3 � Billing � Tests � 7.2.6 � Product � 2.2.5 � UI � Tests �

  35. Isolated Contract � Artifacts � Pipelines � Tests � 3.1.3 � 3.1.3 � Order Entry � Tests � 4.2.3 � Billing � Tests � 7.2.6 � Product � 2.2.5 � UI � Tests �

  36. UI � 4.2.3 � Order Billing � Entry � 7.2.6 � Product �

  37. Isolated Contract � Artifacts � Pipelines � Tests � 3.1.3 � Order Entry � Tests � 4.2.3 � Order Billing � Entry-3.1.3 � Tests � Billing-4.2.3 � Product-7.2.6 � 7.2.6 � Product � UI-2.2.5 � 2.2.5 � UI � Tests �

  38. Isolated Contract � Artifacts � Pipelines � Tests � 3.1.3 � Order Entry � Tests � 4.2.3 � Billing � Tests � 7.2.6 � Product � 2.2.5 � UI � Tests �

  39. [Test] ¡ public ¡void ¡ValidateProductAttributes() ¡ { ¡ ¡ ¡ ¡ ¡var ¡url ¡= ¡UrlForTestProduct(); ¡ ¡ ¡ ¡ ¡var ¡response ¡= ¡new ¡HttpResource(url) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡.ThatAccepts("application/xml") ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡.Get(); ¡ ¡ ¡ ¡ ¡ ¡Assert.That(response.StatusCode, ¡Is.EqualTo(200)); ¡ ¡ ¡ ¡ ¡AssertHasXPath(response.Body, ¡"//productCode"); ¡ ¡ ¡ ¡ ¡AssertHasXPath(response.Body, ¡"//description"); ¡ ¡ ¡ ¡ ¡AssertHasXPath(response.Body, ¡"//monthlyCharge"); ¡ ¡ ¡ ¡ ¡AssertNumeric(ValueFor(response.Body, ¡"//monthlyCharge")); ¡ } ¡

  40. use bounded contexts to control complexity

  41. Rates � CSR UI � Product � Finance � Provisioning � Catalog � Invoicing � Billing � Marketing / � Website �

  42. data rationalization

  43. Conway’s Law Organizations which design In every organization there will systems ... are constrained to always be one person who knows produce designs what is going on. This person must which are copies of the be fired. communication structures of these organizations

  44. augment � finance � record event � augment � get events � create � billing � product � augment � invoice �

  45. twitter:@BrandonByars � http://martinfowler.com/articles/enterpriseREST.html �

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend