nexaas-async-collector 1.0.2 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -2
- data/app/controllers/nexaas/async/collector/async_resource_controller.rb +2 -0
- data/app/helpers/nexaas/async/collector/application_helper.rb +6 -0
- data/app/views/nexaas/async/collector/async_resource/_show.html.erb +1 -1
- data/app/workers/nexaas/async/collector/async_resource_job.rb +1 -1
- data/config/routes.rb +2 -2
- data/lib/nexaas/async/collector.rb +4 -0
- data/lib/nexaas/async/collector/engine.rb +6 -0
- data/lib/nexaas/async/collector/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10fc3220c993eadd31eeeea97cb1df5e80494f06
|
4
|
+
data.tar.gz: 88b146d82cb06133baf6822b9c82b5a2f4abfaa2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6191da8490ee082bec3015795c3b890db54e70b0ee146a3de114a61681024750ddd9b38f00ca75678fd46d024a75a4e5353fd707d23cd3ccd2722b9bbee5fa79
|
7
|
+
data.tar.gz: 23b9fac62ee720198cf8330c06db2a5ae4c605ebf235f79e25df0a6051cb19c98ff0261ab3bfd884e853370bd26edd5c8a4e59249b54758f0a723e5c1d5313f2
|
data/README.md
CHANGED
@@ -45,6 +45,9 @@ $ gem install nexaas-async-collector
|
|
45
45
|
# The namespace where you want to store you data within Redis
|
46
46
|
config.redis_namespace = 'nexaas_async'
|
47
47
|
|
48
|
+
# The name of the sidekiq queue to be used
|
49
|
+
config.queue_name = :high_fast
|
50
|
+
|
48
51
|
# The method that returns the user object (or any other object you want. It must respond to id method)
|
49
52
|
config.scope = :current_user
|
50
53
|
|
@@ -53,10 +56,20 @@ $ gem install nexaas-async-collector
|
|
53
56
|
end
|
54
57
|
```
|
55
58
|
|
56
|
-
2)
|
59
|
+
2) Add this to your *config/routes.rb* file:
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
Rails.application.routes.draw do
|
63
|
+
# ...
|
64
|
+
mount Nexaas::Async::Collector::Engine => '/nexaas_async_collect'
|
65
|
+
# ...
|
66
|
+
end
|
67
|
+
```
|
68
|
+
|
69
|
+
3) Use the view helper to do all the process:
|
57
70
|
|
58
71
|
```ruby
|
59
|
-
<%=
|
72
|
+
<%= nexaas_async_collect(user.id, ModelService, :model_method, [arg1, arg2]) %>
|
60
73
|
```
|
61
74
|
|
62
75
|
## Contributing
|
@@ -17,6 +17,12 @@ module Nexaas
|
|
17
17
|
render(partial: 'nexaas/async/collector/async_resource/show')
|
18
18
|
end
|
19
19
|
|
20
|
+
# Rails 4.x does not add this helper automatically as Rails 5.X and 3.X does. So we had to created it to keep
|
21
|
+
# the same interface.
|
22
|
+
def nexaas_async_collector
|
23
|
+
@@nexaas_async_collector ||= Nexaas::Async::Collector::Engine.routes.url_helpers
|
24
|
+
end
|
25
|
+
|
20
26
|
private
|
21
27
|
|
22
28
|
def collector_user_id
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<script type="text/javascript" id="js-nexaas-async-collector">
|
2
2
|
var requestContent = function() {
|
3
3
|
$.ajax({
|
4
|
-
url: '<%=
|
4
|
+
url: '<%= nexaas_async_collector.async_resource_path(@collector_user_id) %>',
|
5
5
|
dataType: 'script'
|
6
6
|
})
|
7
7
|
}
|
@@ -4,7 +4,7 @@ module Nexaas
|
|
4
4
|
class AsyncResourceJob
|
5
5
|
|
6
6
|
include Sidekiq::Worker
|
7
|
-
sidekiq_options queue:
|
7
|
+
sidekiq_options queue: Nexaas::Async::Collector.queue_name
|
8
8
|
|
9
9
|
def perform(collector_id, user_id, klass_name, klass_method, args=[])
|
10
10
|
content = call_for_method(klass_name, klass_method, args)
|
data/config/routes.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
Nexaas::Async::Collector::Engine.routes.draw do
|
2
|
+
resources :async_resource, only: :show
|
3
3
|
end
|
@@ -17,6 +17,10 @@ module Nexaas
|
|
17
17
|
mattr_accessor :redis_namespace
|
18
18
|
@@redis_namespace = 'nexaas_async'
|
19
19
|
|
20
|
+
# Name of the sidekiq queue to be used
|
21
|
+
mattr_accessor :queue_name
|
22
|
+
@@queue_name = :high_fast
|
23
|
+
|
20
24
|
# Method will be called to get the user/account id
|
21
25
|
# This ID is used to store and ensure only the user
|
22
26
|
# will fetch the processed data.
|
@@ -2,6 +2,12 @@ module Nexaas
|
|
2
2
|
module Async
|
3
3
|
module Collector
|
4
4
|
class Engine < ::Rails::Engine
|
5
|
+
isolate_namespace Nexaas::Async::Collector
|
6
|
+
|
7
|
+
config.before_initialize do
|
8
|
+
Nexaas::Async::Collector.parent_controller.constantize.helper(Nexaas::Async::Collector::ApplicationHelper)
|
9
|
+
end
|
10
|
+
|
5
11
|
config.generators do |g|
|
6
12
|
g.test_framework :rspec
|
7
13
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nexaas-async-collector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eduardo Hertz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -42,14 +42,14 @@ dependencies:
|
|
42
42
|
name: redis-namespace
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 1.5.2
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 1.5.2
|
55
55
|
- !ruby/object:Gem::Dependency
|