This document discusses various approaches to coordinating asynchronous HTTP requests and non-blocking I/O in a web application built with Clojure and HttpKit. It presents several solutions using promises and monads to handle asynchronous operations like making a payment on a bill by first retrieving a credit card token, then making a payment, and finally retrieving updated bill details. The solutions range from synchronous code to fully asynchronous approaches using raw promises, promise monads, and chained promises.
3. WHAT IS THE WEB STACK
•
•
•
HttpKit as web server
Compojure for routing
HttpKit for non-blocking http requests
4. REACTIVE APPROACH
PREFERRED
We are not using either Functional Reactive Programming or
Reactive Programming libraries. Eg. Rx.java
• May satisfy other more broad definitions of reactive
• Are making better use of threads than traditional approaches
•
5. Make a payment on a bill
- Not necessarily a full payment
!
POST /bills/:bill-id/payments
Session: user-id
Post Data: amount
!
1. Get credit card token for user
1.1. Send request to payment gateway
2. Find how much was left to be payed
!
If payment is success: render amount remaining on bill
If payment fails: render error
23. HELLO WORLD
• Single
C1-Medium
• 7GB
•8
Ram
Cores
• 313,852
Concurrent Users
• 4756.79
Requests Per
Second
• More
meaningful results
once in SVT with full
implementation
24. ALL DONE AT
AUSTRALIA POST
DIGITAL MAILBOX
They're hiring.
Send your CV to
APDMRecruitment@auspost.com.au