apartment-shoryuken 0.0.1.pre.beta

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
+ SHA1:
3
+ metadata.gz: aa2fe811abebdd1ec3e6057db303097aa9eed810
4
+ data.tar.gz: c4b089b5133cb72eef8c5f933f8e87686d1aa535
5
+ SHA512:
6
+ metadata.gz: 063b6442c3be0fcb21a6033bbca7003c19c595e05a20d43c2df5cabb61c5eed05b27edbf3820cd12a54207ecfbfb178029217f67cd58feeec00a82895ed0af32
7
+ data.tar.gz: cc7a40c16656ea2f973a65e14382ceed86f87f75389ef74ca7111c1dd809901bfafcfc0efb1badfd573e5e02660a9e0860a2ba4bcb56ab37e77d3556f19869dd
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ pkg/
data/Dockerfile ADDED
@@ -0,0 +1,36 @@
1
+ # Ruby image
2
+ FROM ruby:2.2.0
3
+
4
+ # Define Home
5
+ ENV APP_HOME /gem
6
+
7
+ # Install essentials, nodejs and git
8
+ RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs git
9
+
10
+ # Install Bundler
11
+ RUN gem install bundler --no-ri --no-rdoc
12
+
13
+ # Create the folder
14
+ RUN mkdir $APP_HOME
15
+
16
+ # Change the workdir
17
+ WORKDIR $APP_HOME
18
+
19
+ # Add files
20
+ ADD . $APP_HOME
21
+
22
+ # Run bundle install
23
+ # RUN bundle install
24
+
25
+ # Import the gem source code
26
+ VOLUME .:/gem/
27
+
28
+ # Comand
29
+ CMD ["rake", "-T"]
30
+
31
+ # sudo docker build -t yurifrl/apartment-shoryuken .
32
+ # sudo docker run --rm yurifrl/apartment-shoryuken
33
+
34
+ # sudo docker run --rm -v ~/.gitconfig:/root/.gitconfig -v ~/.ssh/:/root/.ssh/ -v ~/.gem/:/root/.gem/ -v `pwd`:/gem/ yurifrl/apartment-shoryuken rake release
35
+ # sudo docker run --rm -ti -v ~/.gitconfig:/root/.gitconfig -v ~/.ssh/:/root/.ssh/ -v ~/.gem/:/root/.gem/ -v `pwd`:/gem/ yurifrl/apartment-shoryuken bash
36
+ # sudo docker run --rm -ti -v ~/.gitconfig:/root/.gitconfig -v ~/.ssh/:/root/.ssh/ -v ~/.gem/:/root/.gem/ -v `pwd`:/gem/ yurifrl/apartment-shoryuken sh release.sh
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in apartment-shoryuken.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Brad Robertson
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # Apartment::Shoryuken
2
+
3
+ Official Support for Shoryuken with the Apartment Gem.
4
+
5
+ This gem takes care of storing the current tenant that a job is enqueued within.
6
+ It will then switch to that tenant for the duration of the job processing.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'apartment-shoryuken'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install apartment-shoryuken
21
+
22
+ ## Usage
23
+
24
+ That's it. There's nothing to do. Each job that is queued will get an additional entry
25
+ storing `Apartment::Tenant.current` when it is queued. Then when the server pops it,
26
+ it will run job within an `Apartment::Tenant.switch` block.
27
+
28
+ ## Contributing
29
+
30
+ 1. Fork it
31
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
32
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
33
+ 4. Push to the branch (`git push origin my-new-feature`)
34
+ 5. Create new Pull Request
35
+
36
+
37
+ [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/influitive/apartment-shoryuken/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
38
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'apartment/shoryuken/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "apartment-shoryuken"
8
+ spec.version = Apartment::Shoryuken::VERSION
9
+ spec.authors = ["Yuri Freire Lima", "Brad Robertson"]
10
+ spec.email = ["yurifrl@outlook.com"]
11
+ spec.description = %q{Enable Multi-tenant supported jobs to work with Shoryuken background worker}
12
+ spec.summary = %q{Shoryuken support for Apartment}
13
+ spec.homepage = "https://github.com/yurifrl/apartment-shoryuken"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency 'minitest'
24
+
25
+ spec.add_dependency 'apartment', '~> 1.0'
26
+ spec.add_dependency 'shoryuken', '>= 1.0.2'
27
+ end
@@ -0,0 +1 @@
1
+ require 'apartment/shoryuken'
@@ -0,0 +1,31 @@
1
+ require 'apartment/shoryuken/version'
2
+ require 'shoryuken'
3
+
4
+ require 'apartment/shoryuken/middleware/client'
5
+ require 'apartment/shoryuken/middleware/server'
6
+
7
+ module Apartment
8
+ module Shoryuken
9
+ module Middleware
10
+ def self.run
11
+ ::Shoryuken.configure_client do |config|
12
+ config.client_middleware do |chain|
13
+ chain.add Apartment::Shoryuken::Middleware::Client
14
+ end
15
+ end
16
+
17
+ ::Shoryuken.configure_server do |config|
18
+ config.client_middleware do |chain|
19
+ chain.add Apartment::Shoryuken::Middleware::Client
20
+ end
21
+
22
+ config.server_middleware do |chain|
23
+ chain.add Apartment::Shoryuken::Middleware::Server
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ require 'apartment/shoryuken/railtie' if defined?(Rails)
@@ -0,0 +1,8 @@
1
+ module Apartment::Shoryuken::Middleware
2
+ class Client
3
+ def call(options)
4
+ options[:message_body]["apartment"] = Apartment::Tenant.current
5
+ yield
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Apartment::Shoryuken::Middleware
2
+ class Server
3
+ def call(worker_instance, queue, sqs_msg, body)
4
+ Apartment::Tenant.switch!(body['apartment'])
5
+ yield
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ module Apartment::Shoryuken
2
+ class Railtie < Rails::Railtie
3
+ initializer "apartment.shoryuken" do
4
+ Apartment::Shoryuken::Middleware.run
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module Apartment
2
+ module Shoryuken
3
+ VERSION = "0.0.1-beta"
4
+ end
5
+ end
data/lib/relase.sh ADDED
@@ -0,0 +1,3 @@
1
+ rake build
2
+ rake install
3
+ rake release
data/release.sh ADDED
@@ -0,0 +1,4 @@
1
+ rake build
2
+ rake install
3
+ rake release
4
+ rake spec
@@ -0,0 +1,3 @@
1
+ ENV['RACK_ENV'] = ENV['RAILS_ENV'] = 'test'
2
+
3
+ require 'minitest/autorun'
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: apartment-shoryuken
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.pre.beta
5
+ platform: ruby
6
+ authors:
7
+ - Yuri Freire Lima
8
+ - Brad Robertson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-10-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.3'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.3'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: minitest
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: apartment
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '1.0'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '1.0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: shoryuken
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 1.0.2
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: 1.0.2
84
+ description: Enable Multi-tenant supported jobs to work with Shoryuken background
85
+ worker
86
+ email:
87
+ - yurifrl@outlook.com
88
+ executables: []
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - ".gitignore"
93
+ - Dockerfile
94
+ - Gemfile
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - apartment-shoryuken.gemspec
99
+ - lib/apartment-shoryuken.rb
100
+ - lib/apartment/shoryuken.rb
101
+ - lib/apartment/shoryuken/middleware/client.rb
102
+ - lib/apartment/shoryuken/middleware/server.rb
103
+ - lib/apartment/shoryuken/railtie.rb
104
+ - lib/apartment/shoryuken/version.rb
105
+ - lib/relase.sh
106
+ - release.sh
107
+ - spec/spec_helper.rb
108
+ homepage: https://github.com/yurifrl/apartment-shoryuken
109
+ licenses:
110
+ - MIT
111
+ metadata: {}
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">"
124
+ - !ruby/object:Gem::Version
125
+ version: 1.3.1
126
+ requirements: []
127
+ rubyforge_project:
128
+ rubygems_version: 2.4.5
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: Shoryuken support for Apartment
132
+ test_files:
133
+ - spec/spec_helper.rb