Skip to content

Commit d44e3a5

Browse files
authored
Merge pull request #16 from customink/installer
Basic Exe Install Interface
2 parents 673df26 + 1fc507f commit d44e3a5

File tree

4 files changed

+38
-21
lines changed

4 files changed

+38
-21
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
## [1.1.0] - 2023-04-16
2+
3+
### Added
4+
5+
- New `lambda_punch` install interface.
6+
17
## [1.0.3] - 2021-10-27
28

39
### Added
410

5-
-
11+
- Any Timeout Gem. Tempfile Location Interface
612

713
### Changed
814

README.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,36 @@ The LambdaPunch extension process is very small and lean. It only requires a few
1818

1919
## 🎁 Installation
2020

21-
Add this line to your project's `Gemfile` and then make sure to `bundle install` afterward.
21+
Add this line to your project's `Gemfile` and then make sure to `bundle install` afterward. It is only needed in the `production` group.
2222

2323
```ruby
2424
gem 'lambda_punch'
2525
```
2626

27-
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.
27+
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.
2828

29-
```ruby
30-
LambdaPunch.start_server!
31-
32-
def handler(event:, context:)
33-
# ...
34-
ensure
35-
LambdaPunch.handled!(context)
36-
end
29+
```dockerfile
30+
RUN gem install lambda_punch && lambda_punch install
3731
```
3832

39-
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.
33+
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.
4034

41-
```dockerfile
42-
RUN bundle exec rake lambda_punch:install
35+
```ruby
36+
config.to_prepare { LambdaPunch.start_server! }
37+
config.lamby.handled_proc = Proc.new do |_event, context|
38+
LambdaPunch.handled!(context)
39+
end
4340
```
4441

45-
If you are using `LambdaPunch` with a non-Rails project, add this to your Rake file
42+
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:
4643

4744
```ruby
48-
spec = Gem::Specification.find_by_name 'lambda_punch'
49-
load "#{spec.gem_dir}/lib/lambda_punch/tasks/install.rake"
45+
LambdaPunch.start_server!
46+
def handler(event:, context:)
47+
# ...
48+
ensure
49+
LambdaPunch.handled!(context)
50+
end
5051
```
5152

5253
## 🧰 Usage
@@ -59,11 +60,11 @@ LambdaPunch.push do
5960
end
6061
```
6162

62-
For example, if you are using Rails with AWS Lambda via the [Lamby](https://lamby.custominktech.com/) v4 (or higher) gem along with [New Relic APM](https://dev.to/aws-heroes/using-new-relic-apm-with-rails-on-aws-lambda-51gi) here is how you configure the handled proc called after `Lamby.cmd` in an `ensure` block. This will force metrics to be flushed after each request.
63+
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:
6364

6465
```ruby
65-
# config/environments/production.rb
66-
config.lambda.handled_proc = Proc.new do |_event, context|
66+
config.to_prepare { LambdaPunch.start_server! }
67+
config.lamby.handled_proc = Proc.new do |_event, context|
6768
LambdaPunch.push { NewRelic::Agent.agent.flush_pipe_data }
6869
LambdaPunch.handled!(context)
6970
end

exe/lambda_punch

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env ruby
2+
3+
require 'rubygems'
4+
require 'rake'
5+
6+
load "#{spec.gem_dir}/lib/lambda_punch/tasks/install.rake"
7+
8+
command = ARGV[0] || 'install'
9+
10+
Rake::Task["lambda_punch:#{command}"].invoke

lib/lambda_punch/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module LambdaPunch
2-
VERSION = "1.0.3"
2+
VERSION = "1.1.0"
33
end

0 commit comments

Comments
 (0)