Document-Driven transactions

44
DELIVERING A BETTER TRANSACTION EXPERIENCE TO YOUR CUSTOMERS BY USING

Transcript of Document-Driven transactions

Page 1: Document-Driven transactions

DELIVERING A BETTER TRANSACTION

EXPERIENCE TO YOUR CUSTOMERS BY USING

Page 2: Document-Driven transactions

REPLICATED DOCUMENT-DRIVEN

TRANSACTIONS

Page 3: Document-Driven transactions

DIGITAL CHECKOUT

EXPERIENCE

Page 4: Document-Driven transactions
Page 5: Document-Driven transactions
Page 6: Document-Driven transactions
Page 7: Document-Driven transactions
Page 8: Document-Driven transactions
Page 9: Document-Driven transactions
Page 10: Document-Driven transactions
Page 11: Document-Driven transactions

THE DUPLICATE TRANSACTION

Page 12: Document-Driven transactions
Page 13: Document-Driven transactions
Page 14: Document-Driven transactions

REPLICATED DOCUMENT-DRIVEN TRANSACTIONS

I’LL BE TALKING ABOUT…

▸ What’s wrong with HTTP APIs for performing transactions?

▸ Proposed solution: Replicated Transaction Documents

▸ A Clerk working on the customer behalf

▸ Demo

Page 15: Document-Driven transactions

WHO AM I?

▸ Pedro Teixeira

▸ @pgte

▸ Partner and Chief Futurist @ YLD

▸ Node.js Developer

▸ Offline-first enthusiast

Page 16: Document-Driven transactions

MOBILE NETWORKS SUCK!

Ilya Gregorik

TEXTO

Page 17: Document-Driven transactions

NOW, GO WATCH ILYA’S TALK

https://youtu.be/aqvz5Oqs238I’LL WAIT…

Page 18: Document-Driven transactions
Page 19: Document-Driven transactions
Page 20: Document-Driven transactions
Page 21: Document-Driven transactions

BLAME HTTP

the use of

Page 22: Document-Driven transactions

REPLICATED DOCUMENT-DRIVEN TRANSACTIONS

WHAT’S WRONG WITH HTTP APIS?

▸ AJAX and RESTful HTTP services have taken us far

▸ In the context of fulfilling a transaction, what happens when an API call fails?

▸ How to react to timeouts / gateway errors / session is lost?

▸ Client code has to handle all the error and related corner cases, persist session, resume session, etc..

▸ Hard to test

Page 23: Document-Driven transactions

TEXTO

LONG-RUNNING TRANSACTIONS

▸How do we support long-running transactions?

▸ Polling

▸ Push (SSE, websockets, XHR LP, …)

▸ ^^ All these exponentially increase the complexity of the client app (and back-end)

Page 24: Document-Driven transactions

REPLICATED DOCUMENT-DRIVEN TRANSACTIONS

WHY?

▸ The proposed solution is nothing new!

▸ But I find that the HTTP API is so ingrained in the developer culture

▸ ^^this, combined with “works fine on my laptop” mentality

▸ Consistently delivers poor customer experience

▸ So I think we need to frame a new abstraction that makes this easier to developers to reason about

Page 25: Document-Driven transactions

A NEW ABSTRACTION

Page 26: Document-Driven transactions

REPLICATED DOCUMENT-DRIVEN TRANSACTIONS

STATUS AND GOALS

▸ This is mostly a work-in-progress that I’d like to share with you

▸ Up for discussion and improvement

▸ Set of open-source libraries that can be combined (instead of a framework) to achieve these goals

Page 27: Document-Driven transactions

HIGH-LEVEL ARCHITECTURE

Page 28: Document-Driven transactions
Page 29: Document-Driven transactions
Page 30: Document-Driven transactions
Page 31: Document-Driven transactions
Page 32: Document-Driven transactions
Page 33: Document-Driven transactions

REPLICATED DOCUMENT-DRIVEN TRANSACTIONS

ONE DOC PER TRANSACTION

▸ Where you store all the data required to

▸ perform the transaction on the server

▸ render the transaction state on the client

▸ Has a state

Page 34: Document-Driven transactions

REPLICATED DOCUMENT-DRIVEN TRANSACTIONS

TRANSACTION FLOW

▸ Document is persisted on the client

▸ Document state is changed on the client or on the clerk

▸ Changes are replicated

▸ Clerk reacts to state transitions, performing back-end actions, which result in a new state

Page 35: Document-Driven transactions
Page 36: Document-Driven transactions

REPLICATED DOCUMENT-DRIVEN TRANSACTIONS

TRANSACTION STATE TRANSITIONS

▸ Transaction state transitions are performed either by the clerk or the client for any given state

▸ Avoiding conflicts

▸ (but conflicts can occur and be resolved)

Page 37: Document-Driven transactions

DEMO!

Page 38: Document-Driven transactions

PROGRAMMING MODEL

Page 39: Document-Driven transactions

OPEN-SOURCE

POUCH-CLERK

▸open-source Node.js package

▸https://github.com/pgte/pouch-clerk

▸Works with CouchDB or PouchDB

Page 40: Document-Driven transactions

PROGRAMMING MODEL

CLERK - HANDLE STATE TRANSITIONS

Page 41: Document-Driven transactions

PROGRAMMING MODEL

CLERK - PERFORM ASYNCHRONOUS UPDATES

Page 42: Document-Driven transactions

SOME OPEN-SOURCE

CLIENT

▸open-source Node.js package

▸https://github.com/pgte/pouch-redux-middleware

▸Syncs (2-way) Redux state with a PouchDB database

Page 43: Document-Driven transactions

READ ON

MORE INFO ON

▸ Authentication

▸ Idem-potency

▸ Scheduling and concurrency

▸ Security

http://bit.ly/29WCmCJ

How to build a reliable transaction experience for your customers

http://bit.ly/29WCmCJ

Page 44: Document-Driven transactions

THANK YOU!