cloud-config 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 22afde03ef83a2749759d80cbdd646a070348effbd70fb7311c92a52dae05869
4
+ data.tar.gz: 16737f0d99ddc1a3bffdf0cad9be1525558efab1565cd21a9552124c1217d838
5
+ SHA512:
6
+ metadata.gz: 1bae934a5af84caeb67f8ba48b9eef08e3f7990ebe26bd577089da7f5d22a253044c499c7c4da0ac4ef92421c934830db4a2b5f21ba52da3892aeb4132eb2a45
7
+ data.tar.gz: 4d528c9e6b3c3e46919bc035424de7e572e87f0eedaaa8a29d38f9aa7fe325f72246ca1b45dc7803ba252c1523d6284f37015e1f3d80e2fe5918ea8838fa7e5d
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,39 @@
1
+ require:
2
+ - rubocop-rake
3
+ - rubocop-rspec
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 3.1
7
+ NewCops: enable
8
+ Exclude:
9
+ - bin/**/*
10
+ - examples/**/*
11
+ - .bundle/**/*
12
+ - .yardoc**/*
13
+ - _yardoc/**/*
14
+ - coverage/**/*
15
+ - doc/**/*
16
+ - pkg/**/*
17
+ - spec/reports/**/*
18
+ - spec/mocks/**/*
19
+ - tmp/**/*
20
+
21
+ Style/StringLiterals:
22
+ Enabled: true
23
+ EnforcedStyle: single_quotes
24
+
25
+ Style/StringLiteralsInInterpolation:
26
+ Enabled: true
27
+ EnforcedStyle: single_quotes
28
+
29
+ Layout/LineLength:
30
+ Max: 120
31
+
32
+ Naming/FileName:
33
+ Enabled: false
34
+
35
+ RSpec/MultipleExpectations:
36
+ Max: 3
37
+
38
+ Metrics/MethodLength:
39
+ Max: 15
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-01-15
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at hypernova2002@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Dockerfile ADDED
@@ -0,0 +1,13 @@
1
+ FROM ruby:3.1.0
2
+
3
+ RUN sed -i 's/http:/https:/' /etc/ssl/openssl.cnf
4
+ RUN apt update
5
+ RUN apt-get install -y libidn11
6
+ RUN mkdir /cloud-config
7
+ WORKDIR /cloud-config
8
+
9
+ COPY . /cloud-config
10
+
11
+ RUN bundle install
12
+
13
+ EXPOSE 4550
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in cloud-config.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,108 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cloud-config (0.1.0)
5
+ parallel
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.2)
11
+ aws-eventstream (1.2.0)
12
+ aws-partitions (1.765.0)
13
+ aws-sdk-core (3.172.0)
14
+ aws-eventstream (~> 1, >= 1.0.2)
15
+ aws-partitions (~> 1, >= 1.651.0)
16
+ aws-sigv4 (~> 1.5)
17
+ jmespath (~> 1, >= 1.6.1)
18
+ aws-sdk-ssm (1.150.0)
19
+ aws-sdk-core (~> 3, >= 3.165.0)
20
+ aws-sigv4 (~> 1.1)
21
+ aws-sigv4 (1.5.2)
22
+ aws-eventstream (~> 1, >= 1.0.2)
23
+ coderay (1.1.3)
24
+ connection_pool (2.4.0)
25
+ diff-lcs (1.5.0)
26
+ jmespath (1.6.2)
27
+ json (2.6.3)
28
+ method_source (1.0.0)
29
+ mock_redis (0.36.0)
30
+ ruby2_keywords
31
+ parallel (1.22.1)
32
+ parser (3.2.0.0)
33
+ ast (~> 2.4.1)
34
+ pry (0.14.2)
35
+ coderay (~> 1.1)
36
+ method_source (~> 1.0)
37
+ rack (3.0.7)
38
+ rainbow (3.1.1)
39
+ rake (13.0.6)
40
+ redis (5.0.6)
41
+ redis-client (>= 0.9.0)
42
+ redis-client (0.14.1)
43
+ connection_pool
44
+ regexp_parser (2.6.1)
45
+ rexml (3.2.5)
46
+ rspec (3.12.0)
47
+ rspec-core (~> 3.12.0)
48
+ rspec-expectations (~> 3.12.0)
49
+ rspec-mocks (~> 3.12.0)
50
+ rspec-core (3.12.0)
51
+ rspec-support (~> 3.12.0)
52
+ rspec-expectations (3.12.2)
53
+ diff-lcs (>= 1.2.0, < 2.0)
54
+ rspec-support (~> 3.12.0)
55
+ rspec-mocks (3.12.2)
56
+ diff-lcs (>= 1.2.0, < 2.0)
57
+ rspec-support (~> 3.12.0)
58
+ rspec-support (3.12.0)
59
+ rubocop (1.43.0)
60
+ json (~> 2.3)
61
+ parallel (~> 1.10)
62
+ parser (>= 3.2.0.0)
63
+ rainbow (>= 2.2.2, < 4.0)
64
+ regexp_parser (>= 1.8, < 3.0)
65
+ rexml (>= 3.2.5, < 4.0)
66
+ rubocop-ast (>= 1.24.1, < 2.0)
67
+ ruby-progressbar (~> 1.7)
68
+ unicode-display_width (>= 2.4.0, < 3.0)
69
+ rubocop-ast (1.24.1)
70
+ parser (>= 3.1.1.0)
71
+ rubocop-capybara (2.18.0)
72
+ rubocop (~> 1.41)
73
+ rubocop-factory_bot (2.23.1)
74
+ rubocop (~> 1.33)
75
+ rubocop-rake (0.6.0)
76
+ rubocop (~> 1.0)
77
+ rubocop-rspec (2.22.0)
78
+ rubocop (~> 1.33)
79
+ rubocop-capybara (~> 2.17)
80
+ rubocop-factory_bot (~> 2.22)
81
+ ruby-progressbar (1.11.0)
82
+ ruby2_keywords (0.0.5)
83
+ timecop (0.9.6)
84
+ unicode-display_width (2.4.2)
85
+ webrick (1.8.1)
86
+ yard (0.9.34)
87
+
88
+ PLATFORMS
89
+ aarch64-linux
90
+
91
+ DEPENDENCIES
92
+ aws-sdk-ssm
93
+ cloud-config!
94
+ mock_redis
95
+ pry
96
+ rack
97
+ rake
98
+ redis
99
+ rspec
100
+ rubocop
101
+ rubocop-rake
102
+ rubocop-rspec
103
+ timecop
104
+ webrick
105
+ yard
106
+
107
+ BUNDLED WITH
108
+ 2.3.3
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 hypernova2002
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,123 @@
1
+ # CloudConfig
2
+
3
+ A library to modernise the way applications fetch configuration. Typically an application will use environment variables and settings files to store and retrieve configurations, but there are many issues with this approach. Often environment variables create a security risk and settings files hard code infrastructure dependencies into the code. Changing configuration settings will usually require redeploying large parts of the infrastructure and perhaps even need to go through the application deployment lifecycle.
4
+
5
+ A modern approach stores configuration remotely, often using key/value databases. Storing configurations in a single database, separately from the codebase reduces infrastructure dependency. Configuration updates can automatically sync with any application, without requiring redeployments. Security risk is greatly reduced, since the configurations can be securely stored. Another goal with this approach is creating an environmentless codebase. The application no longer needs to know which environment it's running in, since all the configuration is handled by the infrastucture.
6
+
7
+ ## Installation
8
+
9
+ Install the gem and add to the application's Gemfile by executing:
10
+
11
+ $ bundle add cloud-config
12
+
13
+ If bundler is not being used to manage dependencies, install the gem by executing:
14
+
15
+ $ gem install cloud-config
16
+
17
+ ## Usage
18
+
19
+ CloudConfig can be configured to fetch keys from multiple providers. Since CloudConfig will need to know which provider has the correct key, all the keys will need to be preconfigured. An example configuration may look like
20
+
21
+ ```ruby
22
+ CloudConfig.configure do
23
+ provider :aws_parameter_store, preload: { async: true } do
24
+ setting :db_url, cache: 60
25
+ setting :api_url
26
+ end
27
+ end
28
+ ```
29
+
30
+ ### Configuration Options
31
+
32
+ ```ruby
33
+ CloudConfig.configure do
34
+ # Set the cache client
35
+ cache_client CloudConfig::Cache::InMemory.new
36
+
37
+ # Configure a provider. You can use the built-in providers (:in_memory, :aws_parameter_store, :yaml_file).
38
+ provider :in_memory do
39
+ end
40
+
41
+ # If you want to configure a custom provider, then please you will need to set the provider_class option.
42
+ provider :custom_provider, provider_class: CustomProvider do
43
+ end
44
+
45
+ # Set the preload option, to enable cache preloading for the provider
46
+ provider :in_memory, preload: true do
47
+ end
48
+
49
+ # Add parallelism for faster preloading
50
+ provider :in_memory, preload: { async: true } do
51
+ end
52
+
53
+ # Configure some keys for a provider
54
+ provider :in_memory do
55
+ setting :key1
56
+ setting :key2
57
+ setting :key3
58
+ end
59
+
60
+ # Configure the setting to be cacheable
61
+ provider :in_memory do
62
+ setting :key1, cache: 60 # 60 seconds
63
+ end
64
+ end
65
+ ```
66
+
67
+ ### Preloading
68
+
69
+ CloudConfig can preload all the keys configured for preload enabled providers. A cache client must be configured, otherwise
70
+ preloading won't do anything.
71
+
72
+ ```ruby
73
+ CloudConfig.configure do
74
+ cache_client CloudConfig::Cache::InMemory.new
75
+
76
+ provider :in_memory, preload: true do
77
+ end
78
+ end
79
+ ```
80
+
81
+ Call preload to cache all the keys.
82
+
83
+ ```ruby
84
+ CloudConfig.preload
85
+ ```
86
+
87
+ ## Development
88
+
89
+ It's recommended to use Docker when working with the library. Assuming Docker is installed, run
90
+
91
+ $ docker-compose run config /bin/bash
92
+
93
+ 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.
94
+
95
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
96
+
97
+ ## Documentation
98
+
99
+ Documentation is built using Yardoc. To build the docs, run
100
+
101
+ $ yardoc
102
+
103
+ To view the documentation, run
104
+
105
+ $ yard server -r
106
+
107
+ or using the docker service
108
+
109
+ $ docker-compose up yardoc
110
+
111
+ The documentation is viewable in the browser at [http://localhost:8808](http://localhost:8808)
112
+
113
+ ## Contributing
114
+
115
+ Bug reports and pull requests are welcome on GitHub at https://github.com/hypernova2002/cloud-config. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/hypernova2002/cloud-config/blob/main/CODE_OF_CONDUCT.md).
116
+
117
+ ## License
118
+
119
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
120
+
121
+ ## Code of Conduct
122
+
123
+ Everyone interacting in the CloudConfig project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/hypernova2002/cloud-config/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/cloud-config/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'cloud-config'
7
+ spec.version = CloudConfig::VERSION
8
+ spec.authors = ['hypernova2002']
9
+ spec.email = ['hypernova2002@gmail.com']
10
+
11
+ spec.summary = 'A library for dynamically reloading settings from cloud services'
12
+ # spec.description = "TODO: Write a longer description or delete this line."
13
+ # spec.homepage = "TODO: Put your gem's website or public repo URL here."
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = '>= 3.1.0'
16
+
17
+ # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
18
+
19
+ # spec.metadata["homepage_uri"] = spec.homepage
20
+ # spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
21
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(__dir__) do
26
+ `git ls-files -z`.split("\x0").reject do |f|
27
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
28
+ end
29
+ end
30
+ spec.bindir = 'exe'
31
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ['lib']
33
+
34
+ # Uncomment to register a new dependency of your gem
35
+ spec.add_dependency 'parallel'
36
+
37
+ spec.add_development_dependency 'aws-sdk-ssm'
38
+ spec.add_development_dependency 'mock_redis'
39
+ spec.add_development_dependency 'pry'
40
+ spec.add_development_dependency 'rack'
41
+ spec.add_development_dependency 'rake'
42
+ spec.add_development_dependency 'redis'
43
+ spec.add_development_dependency 'rspec'
44
+ spec.add_development_dependency 'rubocop'
45
+ spec.add_development_dependency 'rubocop-rake'
46
+ spec.add_development_dependency 'rubocop-rspec'
47
+ spec.add_development_dependency 'timecop'
48
+ spec.add_development_dependency 'webrick'
49
+ spec.add_development_dependency 'yard'
50
+
51
+ # For more information and examples about making a new gem, check out our
52
+ # guide at: https://bundler.io/guides/creating_gem.html
53
+ spec.metadata['rubygems_mfa_required'] = 'true'
54
+ end
@@ -0,0 +1,28 @@
1
+ version: '3.8'
2
+ services:
3
+ config:
4
+ build: .
5
+ stdin_open: true
6
+ tty: true
7
+ environment:
8
+ SSH_AUTH_SOCK: /ssh-agent
9
+ volumes:
10
+ - .:/cloud-config
11
+ - ~/.gitconfig:/root/.gitconfig
12
+ - /run/host-services/ssh-auth.sock:/ssh-agent
13
+ networks:
14
+ - cloud-config
15
+
16
+ yardoc:
17
+ build: .
18
+ command: yard server -r
19
+ volumes:
20
+ - .:/cloud-config
21
+ ports:
22
+ - 8808:8808
23
+ networks:
24
+ - cloud-config
25
+
26
+ networks:
27
+ cloud-config:
28
+ name: cloud_config
@@ -0,0 +1,25 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require 'bundler/inline'
4
+
5
+ gemfile do
6
+ source 'https://rubygems.org'
7
+
8
+ gem 'nokogiri'
9
+ gem 'aws-sdk-ssm'
10
+
11
+ gem 'cloud-config', path: '..'
12
+ end
13
+
14
+ require 'benchmark'
15
+ require 'cloud-config/providers/aws_parameter_store'
16
+
17
+ CloudConfig.configure do
18
+ provider :aws_parameter_store do
19
+ setting :parameter_store_example
20
+ end
21
+ end
22
+
23
+ puts 'Fetching key parameter_store_example'
24
+ value = CloudConfig.get(:parameter_store_example)
25
+ puts "Fetched value #{value}"
@@ -0,0 +1,40 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require 'bundler/inline'
4
+
5
+ gemfile do
6
+ source 'https://rubygems.org'
7
+
8
+ gem 'nokogiri'
9
+ gem 'aws-sdk-ssm'
10
+
11
+ gem 'cloud-config', path: '..'
12
+ end
13
+
14
+ require 'benchmark'
15
+ require 'cloud-config/cache/in_memory'
16
+ require 'cloud-config/providers/aws_parameter_store'
17
+
18
+ CloudConfig.configure do
19
+ cache_client CloudConfig::Cache::InMemory.new
20
+
21
+ provider :aws_parameter_store do
22
+ setting :parameter_store_example, cache: 5
23
+ end
24
+ end
25
+
26
+ value = nil
27
+
28
+ puts 'Fetching key parameter_store_example'
29
+ time = Benchmark.measure { value = CloudConfig.get(:parameter_store_example) }
30
+ puts "Fetched value #{value} in #{time.real.round(5)} seconds"
31
+
32
+ puts 'Fetching key parameter_store_example (cached)'
33
+ time = Benchmark.measure { value = CloudConfig.get(:parameter_store_example) }
34
+ puts "Fetched value #{value} in #{time.real.round(5)} seconds"
35
+
36
+ sleep 5
37
+
38
+ puts 'Fetching key parameter_store_example'
39
+ time = Benchmark.measure { value = CloudConfig.get(:parameter_store_example) }
40
+ puts "Fetched value #{value} in #{time.real.round(5)} seconds"
@@ -0,0 +1,38 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require 'bundler/inline'
4
+
5
+ gemfile do
6
+ source 'https://rubygems.org'
7
+
8
+ gem 'nokogiri'
9
+ gem 'aws-sdk-ssm'
10
+
11
+ gem 'cloud-config', path: '..'
12
+ end
13
+
14
+ require 'benchmark'
15
+ require 'cloud-config/cache/in_memory'
16
+ require 'cloud-config/providers/aws_parameter_store'
17
+
18
+ CloudConfig.configure do
19
+ cache_client CloudConfig::Cache::InMemory.new
20
+
21
+ provider :aws_parameter_store, preload: true do
22
+ setting :parameter_store_example, cache: 5
23
+ end
24
+ end
25
+
26
+ CloudConfig.preload
27
+
28
+ value = nil
29
+
30
+ puts 'Fetching key parameter_store_example (cached)'
31
+ time = Benchmark.measure { value = CloudConfig.get(:parameter_store_example) }
32
+ puts "Fetched value #{value} in #{time.real.round(5)} seconds"
33
+
34
+ sleep 5
35
+
36
+ puts 'Fetching key parameter_store_example'
37
+ time = Benchmark.measure { value = CloudConfig.get(:parameter_store_example) }
38
+ puts "Fetched value #{value} in #{time.real.round(5)} seconds"