SlideShare a Scribd company logo
AWS PHP SDK v3
Asynchronous Requests
Michael Dowling
@mtdowling
AWS PHP SDK v3
Asynchronous Requests
Michael Dowling
@mtdowling
What we’ll cover
• Promises
• Handlers and Middleware
• ReactPHP in the SDK
• A promise represents the eventual result of an
asynchronous operation.
• Promises are values and are composable
https://promisesaplus.com/
Promises/A+
Promises
• A promise has a then() method, which allows
access to its current or eventual value or reason.
• Promises are resolved with a value or rejected
with a reason.
• State transitions: Pending -> (Fulfilled | Rejected)
• Fulfilled and rejected promises are immutable.
https://promisesaplus.com/
Promises
then()
• Calling then() on a promise will return a new promise
that is fulfilled or rejected based on the result of invoking
the provided then($onFullfilled,	
  $onRejected)
callbacks.
• If a callback throws, the promise is rejected and
downstream promises are rejected.
• If a rejected callback does not throw, downstream
promises are fulfilled.
• If a promise is fulfilled or rejected with a promise, any
callbacks registered on the promise will not be invoked
until the promise is resolved.
then()
Promises in the SDK
1.
2.
• Multiple promises can be composed together into a
single promise using combinators
• Guzzle ships with several combinators
Promise Combinators
Promise Combinator
Examples
all($promises)	
  //	
  usage
some($promises)	
  //	
  usage
any($promises)	
  //	
  usage
each_limit($iterable,	
  $concurrency,	
  …)
Promise Coroutines
SDK Pool
Handlers and Middleware
• A handler is a function that performs the actual
transformation of a command and request into
a result (e.g., Guzzle is a handler).
• A middleware is a higher-order function that
modifies a command, request, or result as it
passes through the middleware.
• A HandlerList is used by clients and
commands to compose middleware on a
handler.
Handlers
HandlerList
• A client has a HandlerList that contains a
handler and a list of middleware.
• Each command created by a client get a clone
of the client’s HandlerList that allows per/
command customizations.
HandlerList
• Request lifecycle in the HandlerList
init -> validate -> build -> sign
sign -> build -> validate -> init
execute
returns Promise<Result, Exception>
Command
Adding middleware to
HandlerList
Middleware
Anatomy of a middleware
Example: Validation middleware.
2)	
  Shared	
  state
3)	
  Return	
  a

composable

function
4)	
  Return	
  a

new	
  composed

handler
5)	
  Call	
  the

next	
  handler

and	
  return

a	
  promise
1)	
  Wrapping

function
Higher-order middleware
• Some handlers support async, some emulate.
• cURL handlers support async but must use
wait or you must tick the curl event loop
explicitly.
• Some handlers support async interop with
event loops…
Custom Handlers
Using a custom handler
• http_handler: works at the PSR-7 layer.



handler($request,	
  $options):	
  Promise<Response,	
  Error>
• handler: works at the SDK layer.



handler($command,	
  $request):	
  Promise<Result,	
  Error>
Using a custom handler
React Guzzle Handler
• The SDK supports Guzzle.
• Cees-Jan Kiewiet created a React Guzzle
handler.
• Therefore you can use React with the SDK!
composer	
  require	
  wyrihaximus/react-­‐guzzle-­‐psr7	
  
https://github.com/WyriHaximus/react-guzzle-psr7
Questions?

More Related Content

PPTX
Async discussion 9_29_15
PDF
How to Run a 1,000,000 VU Load Test using Apache JMeter and BlazeMeter
PPTX
Salesforce asynchronous apex
PPT
Weblogic-clustering-failover-and-load-balancing-training
PDF
Test Pyramid in Microservices Context
PPTX
Exactly Once Delivery - Natan Silnitsky
PPTX
Ruby и TestComplete
Async discussion 9_29_15
How to Run a 1,000,000 VU Load Test using Apache JMeter and BlazeMeter
Salesforce asynchronous apex
Weblogic-clustering-failover-and-load-balancing-training
Test Pyramid in Microservices Context
Exactly Once Delivery - Natan Silnitsky
Ruby и TestComplete

What's hot (12)

PPTX
Load Testing with Taurus using Jenkins and AWS
PDF
Introduction to Functional Reactive Programming
PDF
Arquillian & Citrus
PPTX
Why I am hooked on the future of React
PPTX
Salesforce DUG - Queueable Apex
PDF
Observer, a "real life" time series application
PPTX
Batch Apex in Salesforce
PPTX
Batchable vs @future vs Queueable
ODP
Boost your App with Gatling
PPTX
Control your deployments with Capistrano
PPTX
Load Balancing Algorithms - Which one to choose?
PPT
Deploying Rails Apps with Capistrano
Load Testing with Taurus using Jenkins and AWS
Introduction to Functional Reactive Programming
Arquillian & Citrus
Why I am hooked on the future of React
Salesforce DUG - Queueable Apex
Observer, a "real life" time series application
Batch Apex in Salesforce
Batchable vs @future vs Queueable
Boost your App with Gatling
Control your deployments with Capistrano
Load Balancing Algorithms - Which one to choose?
Deploying Rails Apps with Capistrano
Ad

Similar to Php sdk-v3-async (20)

PDF
Continuation_alan_20220503.pdf
PPTX
Angular js 1.0-fundamentals
PPTX
Chapter 05: Eclipse Vert.x - Service Discovery, Resilience and Stability Patt...
PDF
Getting Comfortable with JS Promises
PPTX
Reactive Programming in Java 8 with Rx-Java
PPTX
Angular js introduction
PDF
Client Drivers and Cassandra, the Right Way
PPTX
Flux - An open sourced Workflow orchestrator from Flipkart
PPTX
Soa 31 jax ws server side development architecture
ZIP
Promises in JavaScript with jQuery
PDF
Making the most out of CakePHP 2.2
PPTX
Reactive Java: Promises and Streams with Reakt (JavaOne talk 2016)
PPTX
Reactive Java: Promises and Streams with Reakt (JavaOne Talk 2016)
PPTX
Architecting for Microservices Part 2
KEY
Introduction to Varnish VCL
PPTX
Implementing Micro Services Tasks (service discovery, load balancing etc.) - ...
PPTX
Grails services
PDF
HBaseCon2017 Highly-Available HBase
PDF
Микросервисы со Spring Boot & Spring Cloud
PPTX
Designing Fault Tolerant Microservices
Continuation_alan_20220503.pdf
Angular js 1.0-fundamentals
Chapter 05: Eclipse Vert.x - Service Discovery, Resilience and Stability Patt...
Getting Comfortable with JS Promises
Reactive Programming in Java 8 with Rx-Java
Angular js introduction
Client Drivers and Cassandra, the Right Way
Flux - An open sourced Workflow orchestrator from Flipkart
Soa 31 jax ws server side development architecture
Promises in JavaScript with jQuery
Making the most out of CakePHP 2.2
Reactive Java: Promises and Streams with Reakt (JavaOne talk 2016)
Reactive Java: Promises and Streams with Reakt (JavaOne Talk 2016)
Architecting for Microservices Part 2
Introduction to Varnish VCL
Implementing Micro Services Tasks (service discovery, load balancing etc.) - ...
Grails services
HBaseCon2017 Highly-Available HBase
Микросервисы со Spring Boot & Spring Cloud
Designing Fault Tolerant Microservices
Ad

Recently uploaded (20)

PDF
medical staffing services at VALiNTRY
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
PDF
Complete Guide to Website Development in Malaysia for SMEs
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
Reimagine Home Health with the Power of Agentic AI​
DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Nekopoi APK 2025 free lastest update
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Cost to Outsource Software Development in 2025
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
iTop VPN Free 5.6.0.5262 Crack latest version 2025
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
assetexplorer- product-overview - presentation
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Digital Systems & Binary Numbers (comprehensive )
PPTX
CHAPTER 2 - PM Management and IT Context
medical staffing services at VALiNTRY
Advanced SystemCare Ultimate Crack + Portable (2025)
Complete Guide to Website Development in Malaysia for SMEs
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
Operating system designcfffgfgggggggvggggggggg
Reimagine Home Health with the Power of Agentic AI​
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Nekopoi APK 2025 free lastest update
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Cost to Outsource Software Development in 2025
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
iTop VPN Free 5.6.0.5262 Crack latest version 2025
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
assetexplorer- product-overview - presentation
Design an Analysis of Algorithms II-SECS-1021-03
Wondershare Filmora 15 Crack With Activation Key [2025
Digital Systems & Binary Numbers (comprehensive )
CHAPTER 2 - PM Management and IT Context

Php sdk-v3-async

  • 1. AWS PHP SDK v3 Asynchronous Requests Michael Dowling @mtdowling
  • 2. AWS PHP SDK v3 Asynchronous Requests Michael Dowling @mtdowling
  • 3. What we’ll cover • Promises • Handlers and Middleware • ReactPHP in the SDK
  • 4. • A promise represents the eventual result of an asynchronous operation. • Promises are values and are composable https://promisesaplus.com/ Promises/A+
  • 5. Promises • A promise has a then() method, which allows access to its current or eventual value or reason. • Promises are resolved with a value or rejected with a reason. • State transitions: Pending -> (Fulfilled | Rejected) • Fulfilled and rejected promises are immutable. https://promisesaplus.com/
  • 7. then() • Calling then() on a promise will return a new promise that is fulfilled or rejected based on the result of invoking the provided then($onFullfilled,  $onRejected) callbacks. • If a callback throws, the promise is rejected and downstream promises are rejected. • If a rejected callback does not throw, downstream promises are fulfilled. • If a promise is fulfilled or rejected with a promise, any callbacks registered on the promise will not be invoked until the promise is resolved.
  • 9. Promises in the SDK 1. 2.
  • 10. • Multiple promises can be composed together into a single promise using combinators • Guzzle ships with several combinators Promise Combinators
  • 18. Handlers and Middleware • A handler is a function that performs the actual transformation of a command and request into a result (e.g., Guzzle is a handler). • A middleware is a higher-order function that modifies a command, request, or result as it passes through the middleware. • A HandlerList is used by clients and commands to compose middleware on a handler.
  • 20. HandlerList • A client has a HandlerList that contains a handler and a list of middleware. • Each command created by a client get a clone of the client’s HandlerList that allows per/ command customizations.
  • 21. HandlerList • Request lifecycle in the HandlerList init -> validate -> build -> sign sign -> build -> validate -> init execute returns Promise<Result, Exception> Command
  • 24. Anatomy of a middleware Example: Validation middleware. 2)  Shared  state 3)  Return  a
 composable
 function 4)  Return  a
 new  composed
 handler 5)  Call  the
 next  handler
 and  return
 a  promise 1)  Wrapping
 function
  • 26. • Some handlers support async, some emulate. • cURL handlers support async but must use wait or you must tick the curl event loop explicitly. • Some handlers support async interop with event loops… Custom Handlers
  • 27. Using a custom handler • http_handler: works at the PSR-7 layer.
 
 handler($request,  $options):  Promise<Response,  Error> • handler: works at the SDK layer.
 
 handler($command,  $request):  Promise<Result,  Error>
  • 28. Using a custom handler
  • 29. React Guzzle Handler • The SDK supports Guzzle. • Cees-Jan Kiewiet created a React Guzzle handler. • Therefore you can use React with the SDK! composer  require  wyrihaximus/react-­‐guzzle-­‐psr7   https://github.com/WyriHaximus/react-guzzle-psr7