brefphp / laravel-bridge

Package to use Laravel on AWS Lambda with Bref
https://bref.sh/docs/frameworks/laravel.html
MIT License
314 stars 63 forks source link

Store job attempt in job payload and refactor worker #28

Closed georgeboot closed 3 years ago

georgeboot commented 3 years ago

Fixes #14 Fixes #22

Change 1: Store job attempt in job payload

ApproximateReceiveCount should not be used when processing SQS jobs in Lambda. See https://link.medium.com/uUkT2W9bTbb for more info. This PR adds functionality to store the current attempt on the job payload, so we don't have to depend on ApproximateReceiveCount.

One downside of this, is that because we can't update sqs messages, we always have to re-create a message when releasing it back onto the queue.

Change 2: Refactor workers

This now uses the built-in worker to process jobs. This is more in line with how Laravel processes jobs for other drivers.


The code is 'backwards compatible' in the sense that the example worker.php remains identical. If you did not change that, all should continue working as usual.

The code is heavily inspired (and sometimes copied) from https://github.com/laravel/vapor-core/

georgeboot commented 3 years ago

@mnapoli mind shining some light on this?

mnapoli commented 3 years ago

Thanks, that sounds like an interesting direction and I generally agree this is something worth exploring.

However this PR cannot be merged: it refactors too much stuff without explanations, and more importantly it contains copyrighted code copied without attribution which violates the license of the original code.

I'm going to close this PR, but I am not against going this route.

georgeboot commented 3 years ago

See #31