-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
75e0481
commit 38ee40a
Showing
25 changed files
with
181 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
# This configuration was generated by | ||
# `rubocop --auto-gen-config` | ||
# on 2018-10-03 19:49:44 -0700 using RuboCop version 0.59.2. | ||
# on 2018-10-03 21:01:01 -0700 using RuboCop version 0.59.2. | ||
# The point is for the user to remove these configuration records | ||
# one by one as the offenses are removed from the code base. | ||
# Note that changes in the inspected code, or installation of new | ||
# versions of RuboCop, may require this file to be generated again. | ||
|
||
# Offense count: 1 | ||
# Configuration parameters: CountComments, ExcludedMethods. | ||
Metrics/MethodLength: | ||
Max: 12 | ||
# Offense count: 2 | ||
# Configuration parameters: CustomIncludeMethods. | ||
RSpec/EmptyExampleGroup: | ||
Exclude: | ||
- 'spec/lib/osbourne/queue_spec.rb' | ||
- 'spec/lib/osbourne/topic_spec.rb' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
require "osbourne/railtie" | ||
require "osbourne/services/sns" | ||
require "osbourne/services/sqs" | ||
require "osbourne/topic" | ||
require "osbourne/queue" | ||
|
||
module Osbourne | ||
class << self | ||
attr_accessor :cache | ||
attr_writer :sns_client | ||
def sns_client | ||
@sns_client ||= Aws::SNS::Client.new(Osbourne.sns_config.aws_options) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
require "osbourne/services/sns" | ||
require "osbourne/topic" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# frozen_string_literal: true | ||
|
||
module Osbourne | ||
class Queue | ||
include Services::SQS | ||
attr_reader :name | ||
def initialize(name) | ||
@name = name | ||
arn | ||
end | ||
|
||
def arn | ||
@arn ||= ensure_queue | ||
end | ||
|
||
def ensure_queue | ||
Osbourne.cache.fetch("existing_queue_arn_for_#{name}") do | ||
sns.create_queue(name: name).queue_arn | ||
end | ||
end | ||
|
||
private | ||
|
||
def subscriptions_cache_key | ||
"existing_sqs_subscriptions_for_#{name}" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails" | ||
# require 'osbourne/config/file_loader' | ||
|
||
module Osbourne | ||
class Railtie < Rails::Railtie | ||
config.osbourne = ActiveSupport::OrderedOptions.new | ||
|
||
initializer "osbourne" do | ||
env = ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development" | ||
|
||
%w[config/osbourne.yml.erb config/osbourne.yml].find do |filename| | ||
Osbourne::Config::FileLoader.load(filename, env) | ||
end | ||
end | ||
|
||
initializer "osbourne.logger" do | ||
ActiveSupport.on_load(:osbourne) { self.logger ||= Rails.logger } | ||
end | ||
|
||
initializer "osbourne.cache" do | ||
ActiveSupport.on_load(:osbourne) { self.cache ||= Rails.cache } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
require "aws-sdk-sqs" | ||
|
||
module Osbourne | ||
module Services | ||
module SQS | ||
def sqs | ||
@sqs ||= Osbourne.sqs_client | ||
end | ||
|
||
def sqs=(client) | ||
Osbourne.sqs_client = client | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# frozen_string_literal: true | ||
|
||
module Osbourne | ||
class Topic | ||
include Services::SNS | ||
attr_reader :name | ||
def initialize(name) | ||
@name = name | ||
arn | ||
end | ||
|
||
def arn | ||
@arn ||= ensure_topic | ||
end | ||
|
||
def ensure_topic | ||
Osbourne.cache.fetch("existing_topic_arn_for_#{name}") do | ||
sns.create_topic(name: name).topic_arn | ||
end | ||
end | ||
|
||
private | ||
|
||
def subscriptions_cache_key | ||
"existing_sqs_subscriptions_for_#{name}" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module MessagePlumber | ||
module Osbourne | ||
VERSION = "0.1.0" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# frozen_string_literal: true | ||
|
||
# desc "Explaining what the task does" | ||
# task :message_plumber do | ||
# task :osbourne do | ||
# # Task goes here | ||
# end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,17 +3,17 @@ | |
$LOAD_PATH.push File.expand_path("lib", __dir__) | ||
|
||
# Maintain your gem's version: | ||
require "message_plumber/version" | ||
require "osbourne/version" | ||
|
||
# Describe your gem and declare its dependencies: | ||
Gem::Specification.new do |s| | ||
s.name = "message_plumber" | ||
s.version = MessagePlumber::VERSION | ||
s.name = "osbourne" | ||
s.version = Osbourne::VERSION | ||
s.authors = ["Steve Allen"] | ||
s.email = ["[email protected]"] | ||
s.homepage = "https://github.com/" | ||
s.summary = "A simple implementation of the fan-out message pattern" | ||
s.description = ": Description of MessagePlumber." | ||
s.description = ": Description of Osbourne." | ||
s.license = "MIT" | ||
|
||
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"] | ||
|
@@ -26,12 +26,13 @@ Gem::Specification.new do |s| | |
s.add_development_dependency "awesome_print" | ||
s.add_development_dependency "bundler", "~> 1.8" | ||
s.add_development_dependency "guard" | ||
s.add_development_dependency "guard-bundler" | ||
s.add_development_dependency "guard-rspec" | ||
s.add_development_dependency "mock_redis" | ||
s.add_development_dependency "pry-byebug" | ||
s.add_development_dependency "rake", "~> 10.0" | ||
s.add_development_dependency "redis" | ||
s.add_development_dependency "rspec", "~> 3.2" | ||
s.add_development_dependency "rspec", "~> 3" | ||
s.add_development_dependency "rubocop" | ||
s.add_development_dependency "rubocop-rspec" | ||
s.add_development_dependency "simplecov" | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
RSpec.describe Osbourne::Queue, type: :model do | ||
subject { described_class.new(queue_name) } | ||
|
||
let(:sqs_client) { instance_double("Aws::SQS::Client") } | ||
let(:queue_arn) { OpenStruct.new(queue_arn: "arn:aws:sqs:us-east-2:123456789012:queue") } | ||
let(:queue_name) { "queue_name" } | ||
|
||
before { | ||
allow(sqs_client).to receive(:create_queue).and_return(queue_arn) | ||
Osbourne.sqs_client = sqs_client | ||
} | ||
end |
File renamed without changes.
Oops, something went wrong.