From 6bb189d7fbbcb75bd49a7f3efe8bc3963a174a8a Mon Sep 17 00:00:00 2001 From: Ian Oxley Date: Mon, 7 Aug 2023 16:05:15 +0100 Subject: [PATCH 01/28] Sort dependencies --- eventq.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eventq.gemspec b/eventq.gemspec index 8e607b7..361f229 100644 --- a/eventq.gemspec +++ b/eventq.gemspec @@ -24,8 +24,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'shoulda-matchers' spec.add_development_dependency 'simplecov', '< 0.18.0' - spec.add_dependency 'aws-sdk-sqs', '~> 1' spec.add_dependency 'aws-sdk-sns', '~> 1' + spec.add_dependency 'aws-sdk-sqs', '~> 1' spec.add_dependency 'bunny' spec.add_dependency 'class_kit' spec.add_dependency 'concurrent-ruby' From edf135b8bf53abf206757781ea705b23317724ab Mon Sep 17 00:00:00 2001 From: Ian Oxley Date: Mon, 7 Aug 2023 16:32:40 +0100 Subject: [PATCH 02/28] Update Dockerfile and docker-compose.yml Move both files to the project root. Remove specific gem versions from Dockerfile, and rely on those specified in the gemspec and Gemfile. Fix path in GitHub Actions workflow after moving docker-compose.yml. --- .github/workflows/rspec.yml | 1 - Dockerfile | 17 +++++++++++++++++ script/docker-compose.yml => docker-compose.yml | 6 +++--- script/Dockerfile | 14 -------------- 4 files changed, 20 insertions(+), 18 deletions(-) create mode 100644 Dockerfile rename script/docker-compose.yml => docker-compose.yml (88%) delete mode 100644 script/Dockerfile diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index 8d4e31e..2df6406 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -11,7 +11,6 @@ jobs: - name: Run tests run: | - cd script docker-compose up -d docker exec testrunner bash -c "cd src && bundle install && bundle exec rspec && exit" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..27dd706 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM ruby:2.4-alpine3.8 + +RUN apk add --update ca-certificates bash && update-ca-certificates && rm -rf /var/cache/apk/* +RUN apk update && apk add --no-cache build-base + +RUN set -ex \ + && apk add --no-cache --virtual .gem-builddeps \ + ruby-dev build-base libressl-dev + +ENV APP_HOME /src +RUN mkdir -p $APP_HOME +WORKDIR $APP_HOME + +COPY . $APP_HOME +RUN bundle install +RUN apk del .gem-builddeps + diff --git a/script/docker-compose.yml b/docker-compose.yml similarity index 88% rename from script/docker-compose.yml rename to docker-compose.yml index 6827691..72e0032 100644 --- a/script/docker-compose.yml +++ b/docker-compose.yml @@ -7,14 +7,14 @@ services: dockerfile: Dockerfile image: eventq container_name: testrunner - command: bash -c "./scripts/container_loop.sh" + command: bash -c "/scripts/container_loop.sh" depends_on: - redis - rabbitmq - localstack volumes: - - ./container_loop.sh:/scripts/container_loop.sh - - ../:/src + - ./script/container_loop.sh:/scripts/container_loop.sh + - ./:/src environment: - AWS_ACCESS_KEY_ID=mock_id - AWS_SECRET_ACCESS_KEY=mock_password diff --git a/script/Dockerfile b/script/Dockerfile deleted file mode 100644 index fefeb86..0000000 --- a/script/Dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -FROM ruby:2.4-alpine3.8 - -RUN apk add --update ca-certificates bash && update-ca-certificates && rm -rf /var/cache/apk/* -RUN apk update && apk add --no-cache build-base - -RUN set -ex \ - && apk add --no-cache --virtual .gem-builddeps \ - ruby-dev build-base libressl-dev \ - && gem install -N json --version "2.1.0" \ - && gem install -N oj --version "3.6.10" \ - && gem install -N openssl --version "2.1.1" \ - && gem install -N byebug --version "10.0.2" \ - && gem install -N pry-byebug \ - && apk del .gem-builddeps From 8d7440a4232671d9c2f18cca53cac598c68115ec Mon Sep 17 00:00:00 2001 From: Ian Oxley Date: Mon, 7 Aug 2023 16:33:57 +0100 Subject: [PATCH 03/28] Lock pry-byebug for older Ruby versions in Gemfile --- Gemfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Gemfile b/Gemfile index da67471..858ad3f 100644 --- a/Gemfile +++ b/Gemfile @@ -12,3 +12,7 @@ platforms :ruby do gem 'openssl', '2.1.1' gem 'bunny' end + +group :development, :test do + gem 'pry-byebug', '< 3.10' # 3.10.0 requires Ruby >= 2.7 +end From ec40f0fc45fd099e2f058e6655b3a7b4515dab34 Mon Sep 17 00:00:00 2001 From: Ian Oxley Date: Mon, 7 Aug 2023 16:34:29 +0100 Subject: [PATCH 04/28] Remove rake version lock --- eventq.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eventq.gemspec b/eventq.gemspec index 361f229..c9944c4 100644 --- a/eventq.gemspec +++ b/eventq.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'bundler', '~> 1.11' spec.add_development_dependency 'byebug', '~> 11.0' spec.add_development_dependency 'pry-byebug', '~> 3.9' - spec.add_development_dependency 'rake', '~> 10.0' + spec.add_development_dependency 'rake' spec.add_development_dependency 'rspec' spec.add_development_dependency 'shoulda-matchers' spec.add_development_dependency 'simplecov', '< 0.18.0' From 2adaab645907024a498cb6f48e0b705259fe23c3 Mon Sep 17 00:00:00 2001 From: Ian Oxley Date: Mon, 7 Aug 2023 16:34:46 +0100 Subject: [PATCH 05/28] Fix Rubocop warnings --- Gemfile | 5 +++-- lib/eventq.rb | 5 ++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 858ad3f..8ca61fe 100644 --- a/Gemfile +++ b/Gemfile @@ -1,16 +1,17 @@ +# frozen_string_literal: true + source 'https://rubygems.org' # Specify your gem's dependencies in eventq.gemspec gemspec - gem 'json', '2.1.0' gem 'redlock' platforms :ruby do + gem 'bunny' gem 'oj', '3.6.10' gem 'openssl', '2.1.1' - gem 'bunny' end group :development, :test do diff --git a/lib/eventq.rb b/lib/eventq.rb index fd224e9..2cbfc4b 100644 --- a/lib/eventq.rb +++ b/lib/eventq.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'securerandom' require 'redlock' require 'class_kit' @@ -22,6 +24,3 @@ require_relative 'eventq/eventq_base/signature_providers' require_relative 'eventq/eventq_base/exceptions' require_relative 'eventq/queue_worker' - - - From 123f0aff3ef189198b07ff7af05513964a50ba13 Mon Sep 17 00:00:00 2001 From: Ian Oxley Date: Tue, 8 Aug 2023 09:16:21 +0100 Subject: [PATCH 06/28] Ignore Ctags files --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 5d1c71b..d7eebc8 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,6 @@ process_file.txt spec_run.txt /utilities/plot_results + +tags +*.tags From 74f90d2a557fca3a2790b536547be5b9586f8ba3 Mon Sep 17 00:00:00 2001 From: Ian Oxley Date: Tue, 8 Aug 2023 09:28:35 +0100 Subject: [PATCH 07/28] Replace double with single quotes --- eventq.gemspec | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/eventq.gemspec b/eventq.gemspec index c9944c4..b5fd10c 100644 --- a/eventq.gemspec +++ b/eventq.gemspec @@ -1,19 +1,19 @@ # coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -version = File.read(File.expand_path("EVENTQ_VERSION", __dir__)).strip +version = File.read(File.expand_path('EVENTQ_VERSION', __dir__)).strip Gem::Specification.new do |spec| - spec.name = "eventq" + spec.name = 'eventq' spec.version = version - spec.authors = ["SageOne"] - spec.email = ["sageone@sage.com"] + spec.authors = ['SageOne'] + spec.email = ['sageone@sage.com'] spec.description = spec.summary = 'EventQ is a pub/sub system that uses async notifications and message queues' - spec.homepage = "https://github.com/sage/eventq" - spec.license = "MIT" - spec.files = ["README.md"] + Dir.glob("{bin,lib}/**/**/**") - spec.require_paths = ["lib"] + spec.homepage = 'https://github.com/sage/eventq' + spec.license = 'MIT' + spec.files = ['README.md'] + Dir.glob('{bin,lib}/**/**/**') + spec.require_paths = ['lib'] spec.add_development_dependency 'activesupport', '~> 4' spec.add_development_dependency 'bundler', '~> 1.11' From 5fe2d19104b64af6fb9efd10e3aed195cb7a49ac Mon Sep 17 00:00:00 2001 From: Ian Oxley Date: Tue, 8 Aug 2023 09:28:48 +0100 Subject: [PATCH 08/28] Add frozen_string_literal comment to gemspec --- eventq.gemspec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eventq.gemspec b/eventq.gemspec index b5fd10c..2146c56 100644 --- a/eventq.gemspec +++ b/eventq.gemspec @@ -1,4 +1,5 @@ -# coding: utf-8 +# frozen_string_literal: true + lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) version = File.read(File.expand_path('EVENTQ_VERSION', __dir__)).strip From 1887d7393169ac87a34a8edbec848bd353a60b8c Mon Sep 17 00:00:00 2001 From: Ian Oxley Date: Tue, 8 Aug 2023 09:28:59 +0100 Subject: [PATCH 09/28] Remove bundler version lock from dev dependencies --- eventq.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eventq.gemspec b/eventq.gemspec index 2146c56..7a07848 100644 --- a/eventq.gemspec +++ b/eventq.gemspec @@ -17,7 +17,7 @@ Gem::Specification.new do |spec| spec.require_paths = ['lib'] spec.add_development_dependency 'activesupport', '~> 4' - spec.add_development_dependency 'bundler', '~> 1.11' + spec.add_development_dependency 'bundler' spec.add_development_dependency 'byebug', '~> 11.0' spec.add_development_dependency 'pry-byebug', '~> 3.9' spec.add_development_dependency 'rake' From fb342e07a5c91ff46791c5ee19f030bea7318750 Mon Sep 17 00:00:00 2001 From: Ian Oxley Date: Tue, 8 Aug 2023 09:29:11 +0100 Subject: [PATCH 10/28] Add required_ruby_version --- eventq.gemspec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eventq.gemspec b/eventq.gemspec index 7a07848..cf67ce5 100644 --- a/eventq.gemspec +++ b/eventq.gemspec @@ -16,6 +16,8 @@ Gem::Specification.new do |spec| spec.files = ['README.md'] + Dir.glob('{bin,lib}/**/**/**') spec.require_paths = ['lib'] + spec.required_ruby_version = '>= 2.4' + spec.add_development_dependency 'activesupport', '~> 4' spec.add_development_dependency 'bundler' spec.add_development_dependency 'byebug', '~> 11.0' From fbfcd6b9afbbe63b5ac521b9fa8d1f80d56fc53d Mon Sep 17 00:00:00 2001 From: Ian Oxley Date: Mon, 7 Aug 2023 17:01:49 +0100 Subject: [PATCH 11/28] Replace client #list_topics with resource #topics Use the `Aws::SNS::Resource#topics` to search the topics instead of the `Aws::SNS::Client#list_topics`. This should hopefully remove the intermittent AWS SNS throttling error seen on deployment. --- lib/eventq/eventq_aws/sns.rb | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/lib/eventq/eventq_aws/sns.rb b/lib/eventq/eventq_aws/sns.rb index db1b234..22286bc 100644 --- a/lib/eventq/eventq_aws/sns.rb +++ b/lib/eventq/eventq_aws/sns.rb @@ -8,10 +8,11 @@ module Amazon class SNS @@topic_arns = Concurrent::Hash.new - attr_reader :sns + attr_reader :sns, :sns_resource def initialize(client) @sns = client + @sns_resource = Aws::SNS::Resource.new(client: client) end # Create a TopicArn. if one already exists, it will return a pre-existing ARN from the cache. @@ -67,26 +68,10 @@ def aws_safe_name(name) # Finds the given topic, or returns nil if the topic could not be found # - # @note Responses to list_topics can be paged, so to check *all* topics - # we'll need to request each page of topics using response.next_token for - # until the response no longer contains a next_token. Requests to - # list_topics are throttled to 30 TPS, so in the future we may need to - # handle this if it becomes a problem. - # # @param topic_name [String] the name of the topic to find # @return [String] def find_topic(topic_name) - response = sns.list_topics - topics = response.topics - arn = topics.detect { |topic| topic.topic_arn.end_with?(":#{topic_name}") }&.topic_arn - - while arn.nil? && response.next_token - response = sns.list_topics(next_token: response.next_token) - topics = response.topics - arn = topics.detect { |topic| topic.topic_arn.end_with?(":#{topic_name}") }&.topic_arn - end - - arn + sns_resource.topics.detect { |topic| topic.arn.end_with?(":#{topic_name}") }&.arn end end end From 148d3f6466ddcaf7e9ff8aaae7696a21024a48a5 Mon Sep 17 00:00:00 2001 From: Ian Oxley Date: Tue, 8 Aug 2023 09:44:15 +0100 Subject: [PATCH 12/28] Update formatting --- Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 27dd706..59b4da0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,9 +3,7 @@ FROM ruby:2.4-alpine3.8 RUN apk add --update ca-certificates bash && update-ca-certificates && rm -rf /var/cache/apk/* RUN apk update && apk add --no-cache build-base -RUN set -ex \ - && apk add --no-cache --virtual .gem-builddeps \ - ruby-dev build-base libressl-dev +RUN set -ex && apk add --no-cache --virtual .gem-builddeps ruby-dev build-base libressl-dev ENV APP_HOME /src RUN mkdir -p $APP_HOME From 803e19043fe202e2e162d02187634e174b6ee2d2 Mon Sep 17 00:00:00 2001 From: Ian Oxley Date: Tue, 8 Aug 2023 09:52:12 +0100 Subject: [PATCH 13/28] Update EVENTQ_VERSION to 3.3.1 --- EVENTQ_VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EVENTQ_VERSION b/EVENTQ_VERSION index 15a2799..bea438e 100644 --- a/EVENTQ_VERSION +++ b/EVENTQ_VERSION @@ -1 +1 @@ -3.3.0 +3.3.1 From 7b36b72f693a1ffd2275fdc4865bd5282eef8056 Mon Sep 17 00:00:00 2001 From: Ian Oxley Date: Tue, 8 Aug 2023 09:55:33 +0100 Subject: [PATCH 14/28] Fix rspec.yml workflow after Dockerfile changes --- .github/workflows/rspec.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index 2df6406..625d2b5 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -11,8 +11,8 @@ jobs: - name: Run tests run: | - docker-compose up -d - docker exec testrunner bash -c "cd src && bundle install && bundle exec rspec && exit" + docker-compose up -d --build + docker exec testrunner bash -c "bundle exec rspec && exit" - name: Code Coverage uses: paambaati/codeclimate-action@v2.7.5 From dae4e9ee13d5c03b81d2a887a8b40bb72b328547 Mon Sep 17 00:00:00 2001 From: Ian Oxley Date: Tue, 8 Aug 2023 10:18:26 +0100 Subject: [PATCH 15/28] Update workflow to use docker-compose run --- .github/workflows/rspec.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index 625d2b5..048e42d 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -11,8 +11,7 @@ jobs: - name: Run tests run: | - docker-compose up -d --build - docker exec testrunner bash -c "bundle exec rspec && exit" + docker-compose run --build testrunner bash -c "bundle exec rspec spec" - name: Code Coverage uses: paambaati/codeclimate-action@v2.7.5 From 44969fe11fcf9106aa138e0103dc080bccd2e411 Mon Sep 17 00:00:00 2001 From: Ian Oxley Date: Tue, 8 Aug 2023 10:26:41 +0100 Subject: [PATCH 16/28] Update to latest codeclimate-action --- .github/workflows/rspec.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index 048e42d..1531dce 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -14,7 +14,7 @@ jobs: docker-compose run --build testrunner bash -c "bundle exec rspec spec" - name: Code Coverage - uses: paambaati/codeclimate-action@v2.7.5 + uses: paambaati/codeclimate-action@v5.0.0 env: CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} with: From 5683ef051b12346f79e163a5fe52fc468cb9e1bc Mon Sep 17 00:00:00 2001 From: Ian Oxley Date: Tue, 8 Aug 2023 10:29:22 +0100 Subject: [PATCH 17/28] Remove prefix --- .github/workflows/rspec.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index 1531dce..0b38e45 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -18,7 +18,6 @@ jobs: env: CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} with: - prefix: '/src' coverageLocations: | ${{github.workspace}}/coverage/.resultset.json:simplecov From bcd6e89125b2cf236975d89d401713f09232ca7b Mon Sep 17 00:00:00 2001 From: Ian Oxley Date: Tue, 8 Aug 2023 10:29:35 +0100 Subject: [PATCH 18/28] Add verifyDownload --- .github/workflows/rspec.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index 0b38e45..d977274 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -18,6 +18,7 @@ jobs: env: CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} with: + verifyDownload: true coverageLocations: | ${{github.workspace}}/coverage/.resultset.json:simplecov From 8f9944ffeee4692cd5714c2e5cd2ce038b95525b Mon Sep 17 00:00:00 2001 From: Ian Oxley Date: Tue, 8 Aug 2023 10:32:21 +0100 Subject: [PATCH 19/28] Revert "Update workflow to use docker-compose run" This reverts commit dae4e9ee13d5c03b81d2a887a8b40bb72b328547. --- .github/workflows/rspec.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index d977274..bd2afa3 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -11,7 +11,8 @@ jobs: - name: Run tests run: | - docker-compose run --build testrunner bash -c "bundle exec rspec spec" + docker-compose up -d --build + docker exec testrunner bash -c "bundle exec rspec && exit" - name: Code Coverage uses: paambaati/codeclimate-action@v5.0.0 From db02c3f32a83a9ec8b06ecdd997186ed3919f8bc Mon Sep 17 00:00:00 2001 From: Ian Oxley Date: Tue, 8 Aug 2023 10:32:56 +0100 Subject: [PATCH 20/28] Add spec to rspec command --- .github/workflows/rspec.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index bd2afa3..caca34c 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -12,7 +12,7 @@ jobs: - name: Run tests run: | docker-compose up -d --build - docker exec testrunner bash -c "bundle exec rspec && exit" + docker exec testrunner bash -c "bundle exec rspec spec && exit" - name: Code Coverage uses: paambaati/codeclimate-action@v5.0.0 From 56de7b272f10f77ee0689abdb58d6aaf203d1fa0 Mon Sep 17 00:00:00 2001 From: Ian Oxley Date: Tue, 8 Aug 2023 10:42:52 +0100 Subject: [PATCH 21/28] Update checkout action to v3.5.3 --- .github/workflows/rspec.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index caca34c..d75515e 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3.5.3 - name: Run tests run: | From 68c96dea54ab7dbf2f3bb66f674b3ef8c12888ef Mon Sep 17 00:00:00 2001 From: Ian Oxley Date: Tue, 8 Aug 2023 13:57:52 +0100 Subject: [PATCH 22/28] Update how Resource is created The `client` passed to the constructor looks like it'll be an eventq `AwsQueueClient` rather than an AWS SNS client. So create the `Resource` using that client's `#sns` method. --- lib/eventq/eventq_aws/sns.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/eventq/eventq_aws/sns.rb b/lib/eventq/eventq_aws/sns.rb index 22286bc..cca895c 100644 --- a/lib/eventq/eventq_aws/sns.rb +++ b/lib/eventq/eventq_aws/sns.rb @@ -8,11 +8,10 @@ module Amazon class SNS @@topic_arns = Concurrent::Hash.new - attr_reader :sns, :sns_resource + attr_reader :sns def initialize(client) @sns = client - @sns_resource = Aws::SNS::Resource.new(client: client) end # Create a TopicArn. if one already exists, it will return a pre-existing ARN from the cache. @@ -70,7 +69,8 @@ def aws_safe_name(name) # # @param topic_name [String] the name of the topic to find # @return [String] - def find_topic(topic_name) + def find_topic(topic_name, region = nil) + sns_resource = Aws::SNS::Resource.new(client: client.sns(region)) sns_resource.topics.detect { |topic| topic.arn.end_with?(":#{topic_name}") }&.arn end end From e008beddc51ce75214e0b52c84dd85f79c2ce2a3 Mon Sep 17 00:00:00 2001 From: Ian Oxley Date: Tue, 8 Aug 2023 14:30:16 +0100 Subject: [PATCH 23/28] Revert "Update how Resource is created" This reverts commit 68c96dea54ab7dbf2f3bb66f674b3ef8c12888ef. --- lib/eventq/eventq_aws/sns.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/eventq/eventq_aws/sns.rb b/lib/eventq/eventq_aws/sns.rb index cca895c..22286bc 100644 --- a/lib/eventq/eventq_aws/sns.rb +++ b/lib/eventq/eventq_aws/sns.rb @@ -8,10 +8,11 @@ module Amazon class SNS @@topic_arns = Concurrent::Hash.new - attr_reader :sns + attr_reader :sns, :sns_resource def initialize(client) @sns = client + @sns_resource = Aws::SNS::Resource.new(client: client) end # Create a TopicArn. if one already exists, it will return a pre-existing ARN from the cache. @@ -69,8 +70,7 @@ def aws_safe_name(name) # # @param topic_name [String] the name of the topic to find # @return [String] - def find_topic(topic_name, region = nil) - sns_resource = Aws::SNS::Resource.new(client: client.sns(region)) + def find_topic(topic_name) sns_resource.topics.detect { |topic| topic.arn.end_with?(":#{topic_name}") }&.arn end end From 53c3d7466d1047c700627f8b9cd5daff4f231282 Mon Sep 17 00:00:00 2001 From: Ian Oxley Date: Tue, 8 Aug 2023 14:39:30 +0100 Subject: [PATCH 24/28] Allow resource to be injected via the constructor Use the given argument or create a new `Resource`. --- lib/eventq/eventq_aws/sns.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/eventq/eventq_aws/sns.rb b/lib/eventq/eventq_aws/sns.rb index 22286bc..9f99d77 100644 --- a/lib/eventq/eventq_aws/sns.rb +++ b/lib/eventq/eventq_aws/sns.rb @@ -10,9 +10,9 @@ class SNS attr_reader :sns, :sns_resource - def initialize(client) + def initialize(client, resource = nil) @sns = client - @sns_resource = Aws::SNS::Resource.new(client: client) + @sns_resource = resource || Aws::SNS::Resource.new(client: client) end # Create a TopicArn. if one already exists, it will return a pre-existing ARN from the cache. From 030bdaeb194589b36f6c1aff50c5d181934d75c3 Mon Sep 17 00:00:00 2001 From: Ian Oxley Date: Tue, 8 Aug 2023 14:40:00 +0100 Subject: [PATCH 25/28] Remove puts statement from spec_helper.rb --- spec/spec_helper.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c958e97..29fa70d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -7,7 +7,6 @@ SimpleCov.start do add_filter ['spec/'] end -puts 'required simplecov' require 'shoulda-matchers' Shoulda::Matchers.configure do |config| From 9f16555865deb5fdaa31f310b71bd7cb67cf98d2 Mon Sep 17 00:00:00 2001 From: Ian Oxley Date: Tue, 8 Aug 2023 14:40:16 +0100 Subject: [PATCH 26/28] Remove empty before each block --- spec/spec_helper.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 29fa70d..e2dc143 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -20,11 +20,6 @@ require_relative '../lib/eventq/aws' RSpec.configure do |config| - - config.before(:each) do - - end - config.expect_with :rspec do |expectations| expectations.include_chain_clauses_in_custom_matcher_descriptions = true end From b94ce1bdac4ea01ba57ba90bd6aa4027f3a4533f Mon Sep 17 00:00:00 2001 From: Ian Oxley Date: Thu, 31 Aug 2023 14:43:59 +0100 Subject: [PATCH 27/28] Sort env vars in docker-compose.yml --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 72e0032..e8f83eb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,10 +17,10 @@ services: - ./:/src environment: - AWS_ACCESS_KEY_ID=mock_id - - AWS_SECRET_ACCESS_KEY=mock_password - AWS_REGION=eu-west-1 - - AWS_SQS_ENDPOINT=http://localstack:4566 + - AWS_SECRET_ACCESS_KEY=mock_password - AWS_SNS_ENDPOINT=http://localstack:4566 + - AWS_SQS_ENDPOINT=http://localstack:4566 # env_file: # - ../.aws.env From fd4c0169a026e8c4fcf98802081f968e70e9f97c Mon Sep 17 00:00:00 2001 From: Ian Oxley Date: Thu, 31 Aug 2023 14:44:12 +0100 Subject: [PATCH 28/28] Remove redis ports in docker-compose.yml --- docker-compose.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index e8f83eb..723e7d3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -31,8 +31,6 @@ services: redis: image: redis:alpine container_name: eventq_redis - ports: - - "6379:6379" localstack: # changes to multi region support after this version break tests