Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SNS throttling error finding SNS topics #96

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6bb189d
Sort dependencies
ianoxley Aug 7, 2023
edf135b
Update Dockerfile and docker-compose.yml
ianoxley Aug 7, 2023
8d7440a
Lock pry-byebug for older Ruby versions in Gemfile
ianoxley Aug 7, 2023
ec40f0f
Remove rake version lock
ianoxley Aug 7, 2023
2adaab6
Fix Rubocop warnings
ianoxley Aug 7, 2023
123f0af
Ignore Ctags files
ianoxley Aug 8, 2023
74f90d2
Replace double with single quotes
ianoxley Aug 8, 2023
5fe2d19
Add frozen_string_literal comment to gemspec
ianoxley Aug 8, 2023
1887d73
Remove bundler version lock from dev dependencies
ianoxley Aug 8, 2023
fb342e0
Add required_ruby_version
ianoxley Aug 8, 2023
fbfcd6b
Replace client #list_topics with resource #topics
ianoxley Aug 7, 2023
148d3f6
Update formatting
ianoxley Aug 8, 2023
803e190
Update EVENTQ_VERSION to 3.3.1
ianoxley Aug 8, 2023
7b36b72
Fix rspec.yml workflow after Dockerfile changes
ianoxley Aug 8, 2023
dae4e9e
Update workflow to use docker-compose run
ianoxley Aug 8, 2023
44969fe
Update to latest codeclimate-action
ianoxley Aug 8, 2023
5683ef0
Remove prefix
ianoxley Aug 8, 2023
bcd6e89
Add verifyDownload
ianoxley Aug 8, 2023
8f9944f
Revert "Update workflow to use docker-compose run"
ianoxley Aug 8, 2023
db02c3f
Add spec to rspec command
ianoxley Aug 8, 2023
56de7b2
Update checkout action to v3.5.3
ianoxley Aug 8, 2023
68c96de
Update how Resource is created
ianoxley Aug 8, 2023
e008bed
Revert "Update how Resource is created"
ianoxley Aug 8, 2023
53c3d74
Allow resource to be injected via the constructor
ianoxley Aug 8, 2023
030bdae
Remove puts statement from spec_helper.rb
ianoxley Aug 8, 2023
9f16555
Remove empty before each block
ianoxley Aug 8, 2023
b94ce1b
Sort env vars in docker-compose.yml
ianoxley Aug 31, 2023
fd4c016
Remove redis ports in docker-compose.yml
ianoxley Aug 31, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/rspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ jobs:

- name: Run tests
run: |
cd script
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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is && exit here to try and control the exit code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know TBH 🤷‍♂️

I did change this to use docker-compose run in dae4e9e instead.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah, it would have been due to using docker exec, to exit the container.


- name: Code Coverage
uses: paambaati/codeclimate-action@v2.7.5
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@
process_file.txt
spec_run.txt
/utilities/plot_results

tags
*.tags
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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

2 changes: 1 addition & 1 deletion EVENTQ_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.0
3.3.1
9 changes: 7 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
# 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
gem 'pry-byebug', '< 3.10' # 3.10.0 requires Ruby >= 2.7
end
6 changes: 3 additions & 3 deletions script/docker-compose.yml → docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 15 additions & 12 deletions eventq.gemspec
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
# 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
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.required_ruby_version = '>= 2.4'

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', '~> 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'

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'
Expand Down
5 changes: 2 additions & 3 deletions lib/eventq.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'securerandom'
require 'redlock'
require 'class_kit'
Expand All @@ -22,6 +24,3 @@
require_relative 'eventq/eventq_base/signature_providers'
require_relative 'eventq/eventq_base/exceptions'
require_relative 'eventq/queue_worker'



21 changes: 3 additions & 18 deletions lib/eventq/eventq_aws/sns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
14 changes: 0 additions & 14 deletions script/Dockerfile

This file was deleted.