aws-dev-utils 1.4.5 → 1.4.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8b0b00bc92f14545ee09e8bbcbed7faf6157a65baefd27b7bfc2e0efe4c036e
4
- data.tar.gz: 0f4491633cd884b69007d55f44630f866c01d5f186fdb49f88dab43254a4023b
3
+ metadata.gz: 6ab2dec38839d84640e933f6f35f1502e037d72b5957fdca85afeb100225d30e
4
+ data.tar.gz: d38c4e8f57dfa279dbadea34705a0214cdf1d66579b36e2a0e0a240b2b579c35
5
5
  SHA512:
6
- metadata.gz: e127faa71bf9a1ebbc9cbc61ee21ddb85f50ad939fd9265875bfe78547a3140fe8d585ca9a615251782104c1edf863419eebbafa3d4197da309a6f9b8a3cb35c
7
- data.tar.gz: b68e630e50243ce54e219ff4ce460d2f1ea15573a53ae85095bb341e33860f238add531e004caadc87376a797756f84e37386006dbe98faa36b57e916f908135
6
+ metadata.gz: 426d59404091399a213f9d20ccd751b7f338a723b35fa355c79590b29a08705be47825abf60f34a91a84be1481ea78dd2b5b3e9543ee956cdd67c81fd7d62aba
7
+ data.tar.gz: 20b2136f85898598367eb5fdc1ce6cd1d5ba6e8ebb9b78513180b6358eed36fe49e94272a9c7e6bba8200925cc14a65c3e9d4a6f874ee53a9ddb8d5accb9f8ba
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Amobee BI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,167 @@
1
+ # AWS Dev Utilities [![Build Status](https://travis-ci.org/kontera-technologies/aws-dev-utils.svg?branch=master)](https://travis-ci.org/kontera-technologies/aws-dev-utils) [![codecov](https://codecov.io/gh/kontera-technologies/aws-dev-utils/branch/master/graph/badge.svg)](https://codecov.io/gh/kontera-technologies/aws-dev-utils)
2
+
3
+ This library provides common ruby utilities to working with AWS SDK. It simplifies the work by reducing common boilerplates such as "next_token" pagination and "retry".
4
+ It provides a general API Wrapper with Redis based caching, paging and retry functionalities.
5
+
6
+ ## Installation
7
+ AWS Dev Utilities is available from RubyGems.
8
+
9
+ ### Option 1: Via Bundler
10
+ Add the following to your application's Gemfile:
11
+ ```ruby
12
+ gem 'aws-dev-utils', '~> 1.4'
13
+ ```
14
+ And then execute:
15
+ ```
16
+ $ bundle install
17
+ ```
18
+ ### Option 2: Via `gem install`
19
+ Execute the following inside your application directory:
20
+ ```
21
+ $ gem install aws-dev-utils -v '~> 1.4'
22
+ ```
23
+ ## Usage
24
+ Add the following at the top of each Ruby script, or in each module/class you want to use the `with_next_token`, `with_cache` or `with_retry` functions:
25
+ ```ruby
26
+ require 'aws-dev-utils'
27
+ using AwsDevUtils::Refinements
28
+ ```
29
+
30
+ ## with_next_token
31
+ Many AWS operations limit the number of results returned with each response. To make it easy to get the next page of results, every AWS response object is enumerable.
32
+ This functionality is rarely needed and causes a lot of boilerplate code.
33
+ Using the `client.with_next_token` the paged results will be collected for you.
34
+ The AWS client function and its results will be concatenated until either no more results are available or the max number of requests is reached.
35
+ _`with_next_token` works with APIs that use `next_token`, `next_marker` or `next_continuation_token`._
36
+
37
+ ```ruby
38
+ require 'aws-dev-utils'
39
+ using AwsDevUtils::Refinements
40
+
41
+ ec2_client = Aws::EC2::Client.new
42
+ # To get the full set of results:
43
+ ec2_client.
44
+ with_next_token.
45
+ describe_instances(filters:[{ name: "vpc-id", values: ["vpc-foo"]}])
46
+
47
+ # To get up to 5 pages of results:
48
+ ec2_client.
49
+ with_next_token(5).
50
+ describe_instances(filters:[{ name: "vpc-id", values: ["vpc-foo"]}])
51
+ ```
52
+
53
+ ## with_cache
54
+ In many cases a cache is required due to many processes or different machines querying the AWS api for data.
55
+ By using the `client.with_cache`, the client functions results will be stored in cache.
56
+ The default cache is a simple in memory *time based* store - `AwsDevUtils::Backend::Memory`.
57
+ Incase in-memory cache is not a good solution then there is also `Redis` based caching (`AwsDevUtils::Backend::Redis`).
58
+ To use it, start a Redis instance and set it as the global cache backend:
59
+ ```ruby
60
+ AwsDevUtils::Cache.instance.backend = AwsDevUtils::Backend::Redis.new("redis-url")
61
+ ```
62
+
63
+ _Note: Data will be restored from the cache only if it is the same request to AWS client, the same filters and the same expiration time ._
64
+
65
+ - ```ruby
66
+ # Memory Caching.
67
+ require 'aws-dev-utils'
68
+ using AwsDevUtils::Refinements
69
+
70
+ ec2_client = Aws::EC2::Client.new
71
+ ec2_client.
72
+ with_cache.
73
+ describe_instances(filters:[{ name: "vpc-id", values: ["vpc-foo"]}])
74
+ ```
75
+
76
+ - ```ruby
77
+ # Redis based caching with default experiation time (60 seconds).
78
+ require 'aws-dev-utils'
79
+ using AwsDevUtils::Refinements
80
+
81
+ AwsDevUtils::Cache.instance.backend = AwsDevUtils::Backend::Redis.new("redis-url")
82
+ ec2_client.
83
+ with_cache.
84
+ describe_instances(filters:[{ name: "vpc-id", values: ["vpc-foo"]}])
85
+ ```
86
+
87
+ - ```ruby
88
+ # Redis based caching with custom expiration time (10 minutes).
89
+ require 'aws-dev-utils'
90
+ using AwsDevUtils::Refinements
91
+
92
+ AwsDevUtils::Cache.instance.backend = AwsDevUtils::Backend::Redis.new("redis-url")
93
+ ec2_client.
94
+ with_cache(600).
95
+ describe_instances(filters:[{ name: "vpc-id", values: ["vpc-foo"]}])
96
+ ```
97
+
98
+ - ```ruby
99
+ # Example of different cache keys from requests.
100
+ require 'aws-dev-utils'
101
+ using AwsDevUtils::Refinements
102
+
103
+ AwsDevUtils::Cache.instance.backend = AwsDevUtils::Backend::Redis.new("redis-url")
104
+
105
+ # No cache data so request goes to AWS servers.
106
+ foo_1_instances = ec2_client.
107
+ with_cache(600).
108
+ describe_instances(filters:[{ name: "vpc-id", values: ["vpc-foo"]}])
109
+
110
+ # Different filters than foo_1_instances so request goes to AWS servers.
111
+ bar_1_instances = ec2_client.
112
+ with_cache(600).
113
+ describe_instances(filters:[{ name: "vpc-id", values: ["vpc-bar"]}])
114
+
115
+ # Same filters as bar_1_instances, so result is fetched from cache.
116
+ bar_2_instances = ec2_client.
117
+ with_cache(600).
118
+ describe_instances(filters:[{ name: "vpc-id", values: ["vpc-bar"]}])
119
+
120
+ ```
121
+
122
+ ## with_retry
123
+ By using the `client.with_retry`, the client functions will be retried in case of an exception (until the max number of retries is reached - the default is 5).
124
+ Before each retry the client will sleep for an increasing number of seconds (implements exponential backoff)
125
+ ```ruby
126
+ require 'aws-dev-utils'
127
+ using AwsDevUtils::Refinements
128
+
129
+ ec2_client = Aws::EC2::Client.new
130
+ # Retry 5 times (default):
131
+ ec2_client.
132
+ with_retry.
133
+ describe_instances(filters:[{ name: "vpc-id", values: ["vpc-foo"]}])
134
+
135
+ # Custom retries:
136
+ ec2_client.
137
+ with_retry(3).
138
+ describe_instances(filters:[{ name: "vpc-id", values: ["vpc-foo"]}])
139
+ ```
140
+
141
+ ## Combinations of wrappers
142
+ It is possible to combine between each of the wrappers:
143
+ ```ruby
144
+ require 'aws-dev-utils'
145
+ using AwsDevUtils::Refinements
146
+
147
+ ec2_client = Aws::EC2::Client.new
148
+ #To retry 5 times:
149
+ ec2_client.
150
+ with_retry.
151
+ with_next_token.
152
+ with_cache(600)
153
+ describe_instances(filters:[{ name: "vpc-id", values: ["vpc-foo"]}])
154
+ ```
155
+
156
+ ## Contributing
157
+
158
+ ### Releasing a new version
159
+ The `./release-new-version.sh` script will bump the version number. By default it will
160
+ increase by 0.0.1, but you can pass `minor` or `major` to increase it to the next
161
+ minor or major version accordingly.
162
+
163
+ The script will also create a git commit for the version bump, push it to this
164
+ GitHub repository and upload it to [rubygems.org](https://rubygems.org).
165
+
166
+ ### Bugs and PRs
167
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kontera-technologies/aws-dev-utils
@@ -1,3 +1,3 @@
1
1
  module AwsDevUtils
2
- VERSION = '1.4.5'
2
+ VERSION = '1.4.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-dev-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.5
4
+ version: 1.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Infastructure
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-11 00:00:00.000000000 Z
11
+ date: 2019-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-core
@@ -45,6 +45,8 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - LICENSE
49
+ - README.md
48
50
  - lib/aws-dev-utils.rb
49
51
  - lib/aws-dev-utils/backends/memory.rb
50
52
  - lib/aws-dev-utils/backends/redis.rb