README.md in lambda_punch-1.0.3 vs README.md in lambda_punch-1.1.0
- old
+ new
@@ -2,11 +2,11 @@
![Test](https://github.com/customink/lambda_punch/workflows/Test/badge.svg)
# 👊 LambdaPunch
-<a href="https://lamby.custominktech.com"><img src="https://user-images.githubusercontent.com/2381/59363668-89edeb80-8d03-11e9-9985-2ce14361b7e3.png" alt="Lamby: Simple Rails & AWS Lambda Integration using Rack." align="right" width="300" /></a>Asynchronous background job processing for AWS Lambda with Ruby using [Lambda Extensions](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-extensions-api.html). Inspired by the [SuckerPunch](https://github.com/brandonhilkert/sucker_punch) gem but specifically tooled to work with Lambda's invoke model.
+<a href="https://lamby.custominktech.com"><img src="https://raw.githubusercontent.com/customink/lamby/master/images/social2.png" alt="Lamby: Simple Rails & AWS Lambda Integration using Rack." align="right" width="450" style="margin-left:1rem;margin-bottom:1rem;" /></a>Asynchronous background job processing for AWS Lambda with Ruby using [Lambda Extensions](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-extensions-api.html). Inspired by the [SuckerPunch](https://github.com/brandonhilkert/sucker_punch) gem but specifically tooled to work with Lambda's invoke model.
**For a more robust background job solution, please consider using AWS SQS with the [Lambdakiq](https://github.com/customink/lambdakiq) gem. A drop-in replacement for [Sidekiq](https://github.com/mperham/sidekiq) when running Rails in AWS Lambda using the [Lamby](https://lamby.custominktech.com/) gem.**
## 🏗 Architecture
@@ -16,56 +16,56 @@
The LambdaPunch extension process is very small and lean. It only requires a few Ruby libraries and needed gems from your application's bundle. Its only job is to send signals back to your application on the runtime. It does this within a few milliseconds and adds no noticeable overhead to your function.
## 🎁 Installation
-Add this line to your project's `Gemfile` and then make sure to `bundle install` afterward.
+Add this line to your project's `Gemfile` and then make sure to `bundle install` afterward. It is only needed in the `production` group.
```ruby
gem 'lambda_punch'
```
-Now, within your application's handler file, make sure to start the LambdaPunch DRb server outside of your handler method. Within the handler method, add an `ensure` section that lets the extension process know the request is done.
+Within your project or [Rails application's](https://lamby.custominktech.com/docs/anatomy) `Dockerfile`, add the following. Make sure you do this before you `COPY` your code. The idea is to implicitly use the default `USER root` since it needs permissions to create an `/opt/extensions` directory.
+```dockerfile
+RUN gem install lambda_punch && lambda_punch install
+```
+
+Installation with AWS Lambda via the [Lamby](https://lamby.custominktech.com/) v4 (or higher) gem can be done using Lamby's `handled_proc` config. For example, appends these to your `config/environments/production.rb` file. Here we are ensuring that the LambdaPunch DRb server is running and that after each Lamby request we notify LambdaPunch.
+
```ruby
-LambdaPunch.start_server!
+config.to_prepare { LambdaPunch.start_server! }
+config.lamby.handled_proc = Proc.new do |_event, context|
+ LambdaPunch.handled!(context)
+end
+```
+If you are using an older version of Lamby or a simple Ruby project with your own handler method, the installation would look something like this:
+
+```ruby
+LambdaPunch.start_server!
def handler(event:, context:)
# ...
ensure
LambdaPunch.handled!(context)
end
```
-Within your project or [Rails application's](https://lamby.custominktech.com/docs/anatomy) `Dockerfile`, after you copy your code, add this `RUN` command to install the extension within your container's `/opt/extensions` directory.
-
-```dockerfile
-RUN bundle exec rake lambda_punch:install
-```
-
-If you are using `LambdaPunch` with a non-Rails project, add this to your Rake file
-
-```ruby
-spec = Gem::Specification.find_by_name 'lambda_punch'
-load "#{spec.gem_dir}/lib/lambda_punch/tasks/install.rake"
-```
-
## 🧰 Usage
Anywhere in your application's code, use the `LambdaPunch.push` method to add blocks of code to your jobs queue.
```ruby
LambdaPunch.push do
# ...
end
```
-For example, if you are using Rails with AWS Lambda via the [Lamby](https://lamby.custominktech.com/) gem along with [New Relic APM](https://dev.to/aws-heroes/using-new-relic-apm-with-rails-on-aws-lambda-51gi) here is how your handler function might appear to ensure their metrics are flushed after each request.
+A common use case would be to ensure the [New Relic APM](https://dev.to/aws-heroes/using-new-relic-apm-with-rails-on-aws-lambda-51gi) flushes its data after each request. Using Lamby in your `config/environments/production.rb` file would look like this:
```ruby
-def handler(event:, context:)
- Lamby.handler $app, event, context
-ensure
+config.to_prepare { LambdaPunch.start_server! }
+config.lamby.handled_proc = Proc.new do |_event, context|
LambdaPunch.push { NewRelic::Agent.agent.flush_pipe_data }
LambdaPunch.handled!(context)
end
```