Upgrade to Pro — share decks privately, control downloads, hide ads and more …

おやじのLambda

 おやじのLambda

Event Sourcing and CQRS with AWS Lambda, DynamoDB, SNS
Serverless
Microservices
Clean Architecture

Avatar for Takashi Yagita

Takashi Yagita

February 20, 2019
Tweet

Other Decks in Programming

Transcript

  1. Stock Entity State { 'available’: 17,'reserved’: 3, 'bought’: 2 }

    Stock Methods Calculate(orders, initial_stock) ɾɾɾ Attributes id name state [Orders] Events
  2.  $PNNBOE &WFOU &WFOU 4UPSF 4UBUF %ZOBNP%#4USFBNT 'PMEJOH /INSERT Amazon

    API Gateway Amazon API Gateway 'PMEJOH %FGFSFODF 2VFSZ INSERTͷΈ Query INSERT/REMOVE AT LEAST ONCE Snapshot #BDLVQ /REMOVE Other Service Message .FTTBHF#VT &WFOU 4UPSF
  3.  $PNNBOE &WFOU &WFOU 4UPSF 4UBUF 'PMEJOH /INSERT Amazon API

    Gateway Amazon API Gateway 'PMEJOH %FGFSFODF 2VFSZ INSERTͷΈ Query INSERT/REMOVE AT LEAST ONCE Snapshot ঎඼ࡏݿ ঎඼൪߸ ࡏݿ ཤྺ ೖݿɾग़ݿ
  4. Folding (reduce) Snapshots { 'available’: 17, 'reserved’: 0, 'bought’: 3

    } 5 111 4 { 'available’: 15, 'reserved’: 2, 'bought’: 3 } 111 3 { 'available’: 15, 'reserved’: 5, 'bought’: 0 } 111 { 'available’: 17, 'reserved’: 3, 'bought’: 0 } 2 111 1 version state item id 111 { 'available’: 20, 'reserved’: 0, 'bought’: 0 }
  5. $PNNBOE &WFOU &WFOU 4UPSF 4UBUF %ZOBNP%#4USFBNT 'PMEJOH /INSERT Amazon API

    Gateway Amazon API Gateway 'PMEJOH %FGFSFODF 2VFSZ INSERTͷΈ Query INSERT/REMOVE AT LEAST ONCE Snapshot #BDLVQ /REMOVE Other Service Message .FTTBHF#VT &WFOU 4UPSF Overview (3 ) E ) g S Fd M )3 D M D e U E a ) ) M ) D B )
  6. Controller dict Entity Repository DataStore ResponseObject UseCase RequestObject request_object request_object

    response_object response_object dict dict entity entity entity entity entity dict entity Amazon DynamoDB
  7. device_contrller lambda_handler DeviceRegisterUseCase OipMfpDevice DeviceRepository DeviceDataStore DynamoDB () ) )

    Stock Methods Calculate(orders, initial_stock) ɾɾɾ Attributes id name state [Orders]