yake 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -11
- data/lib/yake/dsl.rb +3 -3
- data/lib/yake/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66fbefc1075634cd8d1e600c992aef045c440a19715f66296695b3cc0c38d45a
|
4
|
+
data.tar.gz: 9d629c68d1ed720382aacefb67608112b404e72488fd6dc4a8b3264cc9b66f56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10c73224492b43a8ec5bbd23d3514e3e6dcf7cf4a8a7158f1f98d1ec9fc013ac7bc4b87084f71a10140466890d6f4da2be27c6e46a172d8c44cc36b691b9f475
|
7
|
+
data.tar.gz: edde64eb9832f62bb4af5730561b314a0daff1b0bed201e1d27cb3a33628ae1922a528fedb2e69444e87d404717e3350dbf1a1b92318ad2da407c303bf9c54a2
|
data/README.md
CHANGED
@@ -26,7 +26,7 @@ require "yake/api"
|
|
26
26
|
|
27
27
|
header "content-type" => "application/json"
|
28
28
|
|
29
|
-
get "/fizz" do
|
29
|
+
get "/fizz" do
|
30
30
|
respond 200, { ok: true }.to_json
|
31
31
|
end
|
32
32
|
|
@@ -59,19 +59,17 @@ Or install it yourself as:
|
|
59
59
|
gem install yake
|
60
60
|
```
|
61
61
|
|
62
|
-
## Why
|
62
|
+
## Why Is It Called "yake"?
|
63
63
|
|
64
|
-
|
64
|
+
"λ" + Rake, but "λ" is hard to type and I think "y" looks like a funny little upside-down-and-backwards Lambda symbol.
|
65
65
|
|
66
|
-
|
66
|
+
## Why Use It?
|
67
67
|
|
68
|
-
`yake`
|
68
|
+
So why use `yake` for your Lambda functions?
|
69
69
|
|
70
70
|
#### Event Logging
|
71
71
|
|
72
|
-
By default, the `handler` function wraps its block in log lines formatted to match the style of Amazon's native Lambda logs sent to CloudWatch. Each invocation of the handler
|
73
|
-
|
74
|
-
Example log lines:
|
72
|
+
By default, the `handler` function wraps its block in log lines formatted to match the style of Amazon's native Lambda logs sent to CloudWatch. Each invocation of the handler will log both the _input event_ and the _returned value_, prefixed with the ID of the request:
|
75
73
|
|
76
74
|
```
|
77
75
|
START RequestId: 149c500f-028a-4b57-8977-0ef568cf8caf Version: $LATEST
|
@@ -82,9 +80,9 @@ END RequestId: 149c500f-028a-4b57-8977-0ef568cf8caf
|
|
82
80
|
REPORT RequestId: 149c500f-028a-4b57-8977-0ef568cf8caf Duration: 43.97 ms Billed Duration: 44 ms Memory Size: 128 MB Max Memory Used: 77 MB
|
83
81
|
```
|
84
82
|
|
85
|
-
|
83
|
+
Logging the request ID in this way makes gathering logs lines for a particular execution in CloudWatch much easier.
|
86
84
|
|
87
|
-
This feature can be disabled by adding a declaration in your handler:
|
85
|
+
This feature can be disabled by adding a declaration in your handler file:
|
88
86
|
|
89
87
|
```ruby
|
90
88
|
logging :off
|
@@ -156,10 +154,14 @@ handler :lambda_handler do |event|
|
|
156
154
|
rescue Yake::UndeclaredRoute => err
|
157
155
|
respond 404, { message: err.message }.to_json
|
158
156
|
rescue => err
|
159
|
-
respond 500 { message: err.message }.to_json
|
157
|
+
respond 500, { message: err.message }.to_json
|
160
158
|
end
|
161
159
|
```
|
162
160
|
|
161
|
+
#### Zero Dependencies
|
162
|
+
|
163
|
+
Finally, `yake` does not depend on any other gems, using the Ruby stdlib only. This helps keep your Lambda packages slim & speedy.
|
164
|
+
|
163
165
|
## Development
|
164
166
|
|
165
167
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/yake/dsl.rb
CHANGED
@@ -16,11 +16,11 @@ module Yake
|
|
16
16
|
|
17
17
|
##
|
18
18
|
# Turn logging on/off
|
19
|
-
def logging(switch, **options)
|
19
|
+
def logging(switch, logdev = $stdout, **options)
|
20
20
|
if switch == :on
|
21
|
-
Yake.logger = Yake::Logger.new
|
21
|
+
Yake.logger = Yake::Logger.new(logdev)
|
22
22
|
elsif switch == :off
|
23
|
-
Yake.logger = nil
|
23
|
+
Yake.logger = ::Logger.new(nil)
|
24
24
|
else
|
25
25
|
raise Errors::UnknownLoggingSetting, switch
|
26
26
|
end
|
data/lib/yake/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Mancevice
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04-
|
11
|
+
date: 2021-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|