-

   rss_rss_hh_new

 - e-mail

 

 -

 LiveInternet.ru:
: 17.03.2011
:
:
: 51

:


CQRS Event Sourcing.

, 19 2017 . 12:21 +
image

, 1 .

, , Query Command, , (Query ) , (Command ). (latency) , Query, Command.

CQRS?


(CQS), Query/Command . Magento CQRS - , - , ( ) .

CQRS SOLID . CQRS (The Single Responsibility Principle) (The Interface Segregation Principle) CRUD.

CQRS , EAV (entity-attribute-value) .
CQRS, , MageCONF 2016 (, ).


Inventory :
  • Source (, ).
  • Source Item -, (SKU) . .
  • Stock (Source) . . Stock ( ) API.
  • Stock Item , Source Stock, (SKU) Stock, .. .
  • Sales Channel . Magento (Website, Store, Store View), , (Country), (Wholesale) . (scope) , Stock .
  • Reservation , , , . , (Source Item) , Stock .

:


Query Command


Theory of operation


. , (State Modification). .

, Query API (StockItem), , (SalesChannel).
ERP PIM Command API (SourceItem) , , StockItem .

.


: , ; , ( ) ( ) .

, .
3 : Source A, Source B, Source C
SKU-1 :
  • SourceItem A 20
  • SourceItem B 25
  • SourceItem C 10
(Sales Channel), Website.
Stock A, (Source A, Source B, Source C).
StockItem A SKU-1 20+25+10 = 55

, Website, Stock, , Stock Item- (SKU) , SKU-1.


30 SKU-1.
  1. ( ), StockItem A SKU-1 = 55 SKU-1 Stock A, 0 ( ), 55 0 > 30, , 30 SKU-1 .
  2. , Source Item . * , .
  3. - SKU-1 StockItem, Read , . (Reservation) SKU-1 Stock A 30 . Append Only , .
  4. .

, :
SKU-1
  • SourceItem A 20
  • SourceItem B 25
  • SourceItem C 10
SKU-1 StockItem A 55 ( ).
Reservation SKU-1 Stock A 30.

, - latency, , SKU-1 10 .

, .
10 SKU-1. : StockItem A SKU-1 = 55 SKU-1 Stock A, 30, 55 30 = 25 > 10 , 10 SKU-1 .

Event Sourcing ( StockItem), , ( Reservation).


, .
, ( ). , , 30 Source Source B
SKU-1 :
  • SourceItem A: 20
  • SourceItem B: 25 20 = 5
  • SourceItem C: 10 10 = 0

SKU-1 Stock A ( Complete), .
Stock Item, .

Magento MSI (Multi Source Inventory)


CQRS Event Sourcing , Magento 2.

, , , github.com/magento-engcom/magento2/projects
Original source: habrahabr.ru (comments, light).

https://habrahabr.ru/post/333678/


: [1] []
 

:
: 

: ( )

:

  URL