async-aws

Jérémy DERUSSÉ

Developer at Blackfire.io

@symfony core team

@jderusse

DX

Developer
eXperience

  • package size (22MiB)
  • dependencies (Guzzle)
  • memory usage
  • >1000 versions + ~1 version/day
  • developer experience
    • no autocompletion
    • complex pagination/async
    • not mockable

aws/aws-sdk-php

@jderusse

@Nyholm

async-aws

install what you need

composer req async-aws/sqs 

composer req async-aws/s3

composer req async-aws/ses

code generated

100% compatible

/**
 * Creates a new standard or FIFO queue. You can pass one or more attributes in the request. 
 * Keep the following in mind:.
 *
 * @see https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_CreateQueue.html
 * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-sqs-2012-11-05.html#createqueue
 *
 * @param array{
 *   QueueName: string,
 *   Attributes?: array<QueueAttributeName::*, string>,
 *   tags?: array<string, string>,
 *   @region?: string,
 * }|CreateQueueRequest $input
 */
public function createQueue($input): CreateQueueResult
{
    $input = CreateQueueRequest::create($input);
    $response = $this->getResponse(
        $input->request(),
        new RequestContext(['operation' => 'CreateQueue', 'region' => $input->getRegion()])
    );
    return new CreateQueueResult($response);
}

readable code

/**
 * aws/aws-sdk-php
 *
 * @method \Aws\Result createQueue(array $args = [])
 * @method \GuzzleHttp\Promise\Promise createQueueAsync(array $args = [])
 */

auto-completion

// pagination
$queues = $sqs->listQueues();
foreach ($queues as $queue) {
    // ...
}

developer eXperience

// async
$file = $s3->getObject([
    'Bucket' => 'my.bucket',
    'Key' => 'file-' . uniqid('file-', true),
]);
$this->doSomethingElse();
$this->save($file->getBody());

you already use it

  • bref/bref
  • bref/symfony-messenger
  • oneup/flysystem-bundle
  • league/flysystem-bundle
  • symfony/amazon-mailer
  • symfony/amazon-sqs-messenger

@jderusse

slides     

Thank you!

Made with Slides.com