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

What is the purpose of this repository? #1

Closed deleugpn closed 4 years ago

deleugpn commented 5 years ago

I noticed this repository has a package-like style and I was wondering if you're thinking about providing a package that makes it easy to use Bref on Laravel context.

I would be willing to provide with a Pull Request that brings 2 components to this repository: Bref Facade and Lambda Queue Job and Worker. You can find the code for these here: https://github.com/deleugpn/laravel-lambda/tree/master/app/Components

The relevance of the Bref Facade is to hide the lambda() helper behind an interface that can be swapped using the Laravel IoC container in order to help writing test code. Laravel developers are used to having a toolbox of test suite easy to use and swap implementations when needed.

The Lambda Worker is an extension of the artisan command queue:work that will fetch events from the lambda() helper (using the facade), build a Laravel job class and send it over to the Worker to work it out.

Another thing I can suggest keeping in this repository would be a version of the artisan file that uses an environment variable to decide which command is being issued: https://github.com/deleugpn/laravel-lambda/blob/master/artisan#L39 The motivation for changing the artisan can be found here: https://github.com/mnapoli/bref/issues/118#issuecomment-464186819

mnapoli commented 4 years ago

Sorry @deleugpn, I'm a year late 😄

Since we don't need the lambda() function anymore, I don't think the facade makes sense anymore.

Regarding queues, I've always wanted to integrate with the native behavior of SQS + Lambda (i.e. not polling messages). I have finally managed to push something. If you have any chance to try that out, or review it, I would love that.

I am also looking for people with Laravel experience to tell me how to make that integration in the Laravel style (i.e. something that looks like Laravel practices). That could be with the naming, with the documentation, etc.

reganjohnson commented 4 years ago

Thanks for putting this out there. Excited to see it released.

If you haven't already, take a look at how Laravel Vapor is handling it's SQS queues, tied into the Laravel systems: https://github.com/laravel/vapor-core/tree/2.0/src/Queue

mnapoli commented 4 years ago

Thanks, yes this directory is exactly what I started doing initially, but went back to using the native SQS integration.

Also, the way Vapor handles queues is very specific and not aligned with how the SQS + Lambda integration works. In short, they adapted Lambda to Laravel. I am adapting Laravel to Lambda. That lets us use all the features of SQS and Lambda.

mnapoli commented 4 years ago

Closing for now, still working on this package with a proper documentation.