Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

Service Oriented Architecture in Magento 2

218 vues

Publié le

During the Magento Meetup London I've had a chance to bring a very interesting for discussion. Service Oriented Architecture in Magento 2. Feel free to share, watch and ask questions if you would like to clarify the approach.

Publié dans : Ingénierie
  • Soyez le premier à commenter

Service Oriented Architecture in Magento 2

  1. 1. Service Oriented Architecture by Max Pronko
  2. 2. About • Founder at Pronko Consulting • 15 years of experience • Magento since 2010 • Certified+ • YouTube.com/maxpronko
  3. 3. • Trainings and Technical Consulting • Magento 2 Development • Payment Integrations www.pronkoconsulting.com Member of
  4. 4. Service Oriented Architecture
  5. 5. What is Service?
  6. 6. A software functionality with a purpose that different clients can reuse for different purposes * wikipedia
  7. 7. Manage Orders Create Order Fulfil Order Ship Order Invoice Order Cancel Order Business Function Services
  8. 8. Domain-Driven Design (DDD)
  9. 9. Service - an operation does not belong to any object
  10. 10. Helpers? Mage::helper(‘catalog’) Original Idea? Kudos: istockphotos.com
  11. 11. Models? class Product { public function save() {}; public function delete() {}; public function validate() {}; public function getData() {}; } Captain Britain, Kudos: tvline.com
  12. 12. Controllers? class ProductController { public function saveAction() {}; public function deleteAction() {}; public function validateAction() {}; public function gridAction() {}; }
  13. 13. Magento 2.0.0.0.0 The very first release version is 0.42.0
  14. 14. 2 Service Isolation
  15. 15. Magento Monolith Presentation Layer Service Contracts Business Logic Database Server DB Storefront & AdminBrowser
  16. 16. Magento Monolith • Easy to introduce an undesired dependency • An application has to be deployed as a whole • An application has to be scaled as a whole
  17. 17. Current State Kudos: Anton Kril
  18. 18. Dependencies - High Coupling
  19. 19. Service Isolation
  20. 20. Service Contracts Atonomy • Data Interfaces • Service Interfaces
  21. 21. Magento Service Contracts • Repository Interfaces • Management Interfaces • Metadata Interfaces
  22. 22. Command Query Responsibility Segregation (SQRS) Kudos: Martin Fowler
  23. 23. CQRS? interface ProductRepositoryInterface { public function save(); public function get(); public function getById(); public function delete(); public function getList(); }
  24. 24. Magento Service Contracts • Repository Interfaces • Management Interfaces • Metadata Interfaces Command Query Query
  25. 25. Service Contract class Product { public function save(); public function delete(); public function validate(); public function getData(); public function load(); } ProductManagementInterface • save() • delete() ProductRepositoryInterface • getList() • getById() ProductInterface • setName() • getName()
  26. 26. Optional Dependency class ProductRepository { public function save($entity) { $this->resource->save($entity); } public function getList() { return $this->collection->load(); } }
  27. 27. Read and Write class Product { public function get() { if (!$this->attributes) { $this->attributes = $this->loadAttributes(); } return $this->attributes; } }
  28. 28. Read and Write class Product { public function setSku($sku) { $this->sku = $sku; return $this; } }
  29. 29. Split Modules
  30. 30. Payments Module Split Realex Payments RealexPaymentsVaultCustomerUi RealexPaymentsVaultApi RealexPaymentsVaultAdminConfigUi RealexPaymentsVaultAdminOrderUi RealexPaymentsVaultCheckoutUi RealexPaymentsVaultWebapi RealexPaymentsVault
  31. 31. Module Decomposition
  32. 32. Split Databases Order Management Checkout rest… • Data Relations • Joins • Transactions
  33. 33. Magento 2 Services Decomposition v2.3 Stage #1 Stage #2 Stage #3 Multi Source Inventory Application Framework Order Management CMS - Pricing Tax Reports - Checkout Customer Payments
  34. 34. Benefits • Easier to comprehend services with less dependencies • Replace Magento built-in services with third-party systems • Scaled independently on Magento instances • Clear ownership boundaries • Granular releases • Easier to use data storage with more appropriate storage models.
  35. 35. Independent Services Kudos: Anton Kril
  36. 36. Custom Modules • Api is the must (Data and Services) • Separate read and write operations (Repository and Management) • Module decoupling
  37. 37. Recommend to Read • Magento Service Isolation http://tiny.cc/9ej67y • Domain-Driven Design book (Amazon) - http://tiny.cc/ uij67y • Building Microservices by Sam Newman - http://tiny.cc/ building-microservices
  38. 38. Recommend to Watch youtube.com/maxpronko
  39. 39. max@pronkoconsulting.com Thank you!

×