geoblacklight_messaging 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +53 -0
- data/.rubocop.yml +18 -0
- data/.travis.yml +22 -0
- data/Gemfile +49 -0
- data/LICENSE +201 -0
- data/README.md +101 -0
- data/Rakefile +48 -0
- data/app/services/geoblacklight_messaging/geoblacklight_event_processor/delete_processor.rb +11 -0
- data/app/services/geoblacklight_messaging/geoblacklight_event_processor/processor.rb +28 -0
- data/app/services/geoblacklight_messaging/geoblacklight_event_processor/unknown_event.rb +15 -0
- data/app/services/geoblacklight_messaging/geoblacklight_event_processor/update_processor.rb +15 -0
- data/app/services/geoblacklight_messaging/geoblacklight_event_processor.rb +29 -0
- data/app/workers/geoblacklight_messaging/geoblacklight_event_handler.rb +16 -0
- data/geoblacklight_messaging.gemspec +32 -0
- data/lib/generators/geoblacklight_messaging/install_generator.rb +30 -0
- data/lib/generators/geoblacklight_messaging/templates/config/initializers/messaging_config.rb +13 -0
- data/lib/generators/geoblacklight_messaging/templates/config/initializers/sneakers.rb +8 -0
- data/lib/generators/geoblacklight_messaging/templates/config/messaging.yml +17 -0
- data/lib/geoblacklight_messaging/engine.rb +5 -0
- data/lib/geoblacklight_messaging/version.rb +3 -0
- data/lib/geoblacklight_messaging.rb +5 -0
- data/lib/tasks/geoblacklight_messaging_tasks.rake +4 -0
- metadata +198 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a09e444a1eccc78c8c0edfc45984f642f45247a4
|
4
|
+
data.tar.gz: 2a568013b7c3a5ccb6682e401debd49f254b74c3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b01b1090dafaa769440c19c186b7963e3eec9bee8718e3a6d825e13e89bcbff376c1c2485d7cba87f0edcc02dca4835797bdabd3d7d28432dae9aa5227171175
|
7
|
+
data.tar.gz: 8b1a12e06ef5e9b8ce177a647bd93caadcea8f42214338abd221f97875e37c7e10b6d50856b1ecde8c3f38e118b0fcde0f60616964e3be3ef9af6b5a3d671eb6
|
data/.gitignore
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
## Specific to RubyMotion:
|
17
|
+
.dat*
|
18
|
+
.repl_history
|
19
|
+
build/
|
20
|
+
*.bridgesupport
|
21
|
+
build-iPhoneOS/
|
22
|
+
build-iPhoneSimulator/
|
23
|
+
|
24
|
+
## Specific to RubyMotion (use of CocoaPods):
|
25
|
+
#
|
26
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
27
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
28
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
29
|
+
#
|
30
|
+
# vendor/Pods/
|
31
|
+
|
32
|
+
## Documentation cache and generated files:
|
33
|
+
/.yardoc/
|
34
|
+
/_yardoc/
|
35
|
+
/doc/
|
36
|
+
/rdoc/
|
37
|
+
|
38
|
+
## Environment normalization:
|
39
|
+
/.bundle/
|
40
|
+
/vendor/bundle
|
41
|
+
/lib/bundler/man/
|
42
|
+
|
43
|
+
# for a library or gem, you might want to ignore these files since the code is
|
44
|
+
# intended to run in multiple environments; otherwise, check them in:
|
45
|
+
# Gemfile.lock
|
46
|
+
# .ruby-version
|
47
|
+
# .ruby-gemset
|
48
|
+
|
49
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
50
|
+
.rvmrc
|
51
|
+
|
52
|
+
.internal_test_app
|
53
|
+
Gemfile.lock
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require: rubocop-rspec
|
2
|
+
|
3
|
+
Rails:
|
4
|
+
Enabled: true
|
5
|
+
|
6
|
+
AllCops:
|
7
|
+
UseCache: false
|
8
|
+
DisplayCopNames: true
|
9
|
+
Include:
|
10
|
+
- '**/Rakefile'
|
11
|
+
|
12
|
+
Metrics/LineLength:
|
13
|
+
Max: 100
|
14
|
+
Exclude:
|
15
|
+
- 'Rakefile'
|
16
|
+
|
17
|
+
Style/Documentation:
|
18
|
+
Enabled: false
|
data/.travis.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
language: ruby
|
2
|
+
cache: bundler
|
3
|
+
sudo: false
|
4
|
+
|
5
|
+
notifications:
|
6
|
+
email: false
|
7
|
+
|
8
|
+
rvm:
|
9
|
+
- 2.3.1
|
10
|
+
|
11
|
+
jdk:
|
12
|
+
- oraclejdk8
|
13
|
+
|
14
|
+
before_install:
|
15
|
+
- gem update --system
|
16
|
+
- gem install bundler
|
17
|
+
|
18
|
+
env:
|
19
|
+
- "RAILS_VERSION=5.0.0.1"
|
20
|
+
|
21
|
+
global_env:
|
22
|
+
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
|
data/Gemfile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in geoblacklight_messaging.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
group :development, :test do
|
7
|
+
# Peg simplecov to < 0.8 until this is resolved:
|
8
|
+
# https://github.com/colszowka/simplecov/issues/281
|
9
|
+
gem 'simplecov', '~> 0.7.1', require: false
|
10
|
+
gem 'coveralls', require: false
|
11
|
+
gem 'rubocop', '0.39.0', require: false
|
12
|
+
gem 'rubocop-rspec', '1.4.1', require: false
|
13
|
+
gem 'byebug', require: false
|
14
|
+
end
|
15
|
+
|
16
|
+
# BEGIN ENGINE_CART BLOCK
|
17
|
+
# engine_cart: 1.0.1
|
18
|
+
# engine_cart stanza: 0.10.0
|
19
|
+
# the below comes from engine_cart, a gem used to test this Rails engine gem in the context of a Rails app.
|
20
|
+
file = File.expand_path('Gemfile', ENV['ENGINE_CART_DESTINATION'] || ENV['RAILS_ROOT'] || File.expand_path('.internal_test_app', File.dirname(__FILE__)))
|
21
|
+
if File.exist?(file)
|
22
|
+
begin
|
23
|
+
eval_gemfile file
|
24
|
+
rescue Bundler::GemfileError => e
|
25
|
+
Bundler.ui.warn '[EngineCart] Skipping Rails application dependencies:'
|
26
|
+
Bundler.ui.warn e.message
|
27
|
+
end
|
28
|
+
else
|
29
|
+
Bundler.ui.warn "[EngineCart] Unable to find test application dependencies in #{file}, using placeholder dependencies"
|
30
|
+
|
31
|
+
if ENV['RAILS_VERSION']
|
32
|
+
if ENV['RAILS_VERSION'] == 'edge'
|
33
|
+
gem 'rails', github: 'rails/rails'
|
34
|
+
ENV['ENGINE_CART_RAILS_OPTIONS'] = '--edge --skip-turbolinks'
|
35
|
+
else
|
36
|
+
gem 'rails', ENV['RAILS_VERSION']
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
case ENV['RAILS_VERSION']
|
41
|
+
when /^4.2/
|
42
|
+
gem 'responders', '~> 2.0'
|
43
|
+
gem 'sass-rails', '>= 5.0'
|
44
|
+
gem 'coffee-rails', '~> 4.1.0'
|
45
|
+
when /^4.[01]/
|
46
|
+
gem 'sass-rails', '< 5.0'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
# END ENGINE_CART BLOCK
|
data/LICENSE
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright {yyyy} {name of copyright owner}
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
# GeoblacklightMessaging
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/eliotjordan/geoblacklight-messaging.svg?branch=master)](https://travis-ci.org/eliotjordan/geoblacklight-messaging) | [![Coverage Status](https://img.shields.io/coveralls/eliotjordan/geoblacklight-messaging.svg)](https://coveralls.io/r/eliotjordan/geoblacklight-messaging?branch=coveralls) | [![Gem Version](https://img.shields.io/gem/v/geoblacklight_messaging.svg)](https://github.com/eliotjordan/geoblacklight-messaging/releases)
|
4
|
+
|
5
|
+
GeoblacklightMessaging is a plugin that enables Geoblacklight applications to synchronize with external services using a RabbitMQ exchange. The plugin subscribes to events on the exchange and updates Geoblacklight records when they're created, updated, or deleted.
|
6
|
+
|
7
|
+
|
8
|
+
## Dependencies
|
9
|
+
|
10
|
+
- [RabbitMQ](https://www.rabbitmq.com/download.html)
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add this line to your Geoblacklight application's Gemfile:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'geoblacklight_messaging'
|
18
|
+
```
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
$ bundle
|
23
|
+
|
24
|
+
Run generator:
|
25
|
+
|
26
|
+
```
|
27
|
+
$ rails generate geoblacklight_messaging:install
|
28
|
+
```
|
29
|
+
|
30
|
+
Configure the events settings in `config/messaging.yml`:
|
31
|
+
|
32
|
+
```yaml
|
33
|
+
defaults: &defaults
|
34
|
+
events:
|
35
|
+
server: <%= ENV['RABBIT_SERVER'] || 'amqp://localhost:5672' %>
|
36
|
+
exchange:
|
37
|
+
geoblacklight: 'gbl_events'
|
38
|
+
```
|
39
|
+
|
40
|
+
## Usage
|
41
|
+
|
42
|
+
1. Start RabbitMQ:
|
43
|
+
|
44
|
+
```
|
45
|
+
$ rabbitmq-server
|
46
|
+
```
|
47
|
+
|
48
|
+
1. Run your geoblacklight application:
|
49
|
+
|
50
|
+
```
|
51
|
+
$ rake geoblacklight:server
|
52
|
+
```
|
53
|
+
|
54
|
+
1. In a separate console, run:
|
55
|
+
|
56
|
+
```
|
57
|
+
$ WORKERS=GeoblacklightMessaging::GeoblacklightEventHandler rake sneakers:run
|
58
|
+
```
|
59
|
+
|
60
|
+
1. If the RabbitMQ Management Plugin is installed, you can inspect the exchange and publish messages manually using the web interface at `http://localhost:15672/`.
|
61
|
+
|
62
|
+
## Message Format
|
63
|
+
|
64
|
+
### Create
|
65
|
+
|
66
|
+
1. The event workers expect a json create message in the following format:
|
67
|
+
|
68
|
+
```json
|
69
|
+
{
|
70
|
+
"id": "princeton-abc123",
|
71
|
+
"event": "CREATED",
|
72
|
+
"doc": { "layer_slug_s": "princeton-abc123", "dc_title_s": "Cool Map", ... }
|
73
|
+
}
|
74
|
+
```
|
75
|
+
|
76
|
+
1. `id` is the record's unique key. `layer_slug_s` in this case.
|
77
|
+
1. `doc` is the unescaped geoblacklight json document.
|
78
|
+
|
79
|
+
|
80
|
+
### Update
|
81
|
+
|
82
|
+
1. Update is similar to create.
|
83
|
+
|
84
|
+
```json
|
85
|
+
{
|
86
|
+
"id": "princeton-abc123",
|
87
|
+
"event": "UPDATED",
|
88
|
+
"doc": { "layer_slug_s": "princeton-abc123", "dc_title_s": "New Map Name", ... }
|
89
|
+
}
|
90
|
+
```
|
91
|
+
|
92
|
+
### Delete
|
93
|
+
|
94
|
+
1. No doc value is needed for delete:
|
95
|
+
|
96
|
+
```json
|
97
|
+
{
|
98
|
+
"id": "princeton-abc123",
|
99
|
+
"event": "DELETED",
|
100
|
+
}
|
101
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'bundler/gem_tasks'
|
8
|
+
require 'rspec/core/rake_task'
|
9
|
+
require 'engine_cart/rake_task'
|
10
|
+
require 'sneakers/tasks'
|
11
|
+
require 'solr_wrapper'
|
12
|
+
require 'rubocop/rake_task'
|
13
|
+
|
14
|
+
desc 'Run style checker'
|
15
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
16
|
+
task.requires << 'rubocop-rspec'
|
17
|
+
task.fail_on_error = true
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'Run test suite and style checker'
|
21
|
+
task spec: :rubocop do
|
22
|
+
RSpec::Core::RakeTask.new(:spec)
|
23
|
+
end
|
24
|
+
|
25
|
+
desc 'Run test suite'
|
26
|
+
task ci: ['geoblacklight:generate'] do
|
27
|
+
SolrWrapper.wrap do |solr|
|
28
|
+
conf_dir = File.join(File.expand_path('.', File.dirname(__FILE__)), '.internal_test_app', 'solr', 'conf')
|
29
|
+
solr.with_collection(name: 'blacklight-core', dir: conf_dir) do
|
30
|
+
Rake::Task['geoblacklight:generate'].invoke
|
31
|
+
Rake::Task['geoblacklight:coverage'].invoke
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
namespace :geoblacklight do
|
37
|
+
desc 'Run tests with coverage'
|
38
|
+
task :coverage do
|
39
|
+
ENV['COVERAGE'] = 'true'
|
40
|
+
Rake::Task['spec'].invoke
|
41
|
+
end
|
42
|
+
|
43
|
+
desc 'Create the test rails app'
|
44
|
+
task generate: ['engine_cart:generate'] do
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
task default: [:ci]
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module GeoblacklightMessaging
|
2
|
+
class GeoblacklightEventProcessor
|
3
|
+
class Processor
|
4
|
+
attr_reader :event
|
5
|
+
def initialize(event)
|
6
|
+
@event = event
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def event_type
|
12
|
+
event['event']
|
13
|
+
end
|
14
|
+
|
15
|
+
def id
|
16
|
+
event['id']
|
17
|
+
end
|
18
|
+
|
19
|
+
def doc
|
20
|
+
event['doc']
|
21
|
+
end
|
22
|
+
|
23
|
+
def index
|
24
|
+
Blacklight.default_index.connection
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module GeoblacklightMessaging
|
2
|
+
class GeoblacklightEventProcessor
|
3
|
+
class UnknownEvent < Processor
|
4
|
+
attr_reader :event
|
5
|
+
def initialize(event)
|
6
|
+
@event = event
|
7
|
+
end
|
8
|
+
|
9
|
+
def process
|
10
|
+
Rails.logger.info("Unable to process event type #{event_type}")
|
11
|
+
false
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module GeoblacklightMessaging
|
2
|
+
class GeoblacklightEventProcessor
|
3
|
+
class UpdateProcessor < Processor
|
4
|
+
def process
|
5
|
+
index.update params: { overwrite: true },
|
6
|
+
data: [doc].to_json,
|
7
|
+
headers: { 'Content-Type' => 'application/json' }
|
8
|
+
index.commit
|
9
|
+
true
|
10
|
+
rescue RSolr::Error::Http
|
11
|
+
false
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module GeoblacklightMessaging
|
2
|
+
class GeoblacklightEventProcessor
|
3
|
+
attr_reader :event
|
4
|
+
def initialize(event)
|
5
|
+
@event = event
|
6
|
+
end
|
7
|
+
|
8
|
+
delegate :process, to: :processor
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def event_type
|
13
|
+
event['event']
|
14
|
+
end
|
15
|
+
|
16
|
+
def processor
|
17
|
+
case event_type
|
18
|
+
when 'CREATED'
|
19
|
+
UpdateProcessor.new(event)
|
20
|
+
when 'UPDATED'
|
21
|
+
UpdateProcessor.new(event)
|
22
|
+
when 'DELETED'
|
23
|
+
DeleteProcessor.new(event)
|
24
|
+
else
|
25
|
+
UnknownEvent.new(event)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module GeoblacklightMessaging
|
2
|
+
class GeoblacklightEventHandler
|
3
|
+
include Sneakers::Worker
|
4
|
+
from_queue :geoblacklight
|
5
|
+
|
6
|
+
def work(msg)
|
7
|
+
msg = JSON.parse(msg)
|
8
|
+
result = GeoblacklightMessaging::GeoblacklightEventProcessor.new(msg).process
|
9
|
+
if result
|
10
|
+
ack!
|
11
|
+
else
|
12
|
+
reject!
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'geoblacklight_messaging/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'geoblacklight_messaging'
|
8
|
+
spec.version = GeoblacklightMessaging::VERSION
|
9
|
+
spec.authors = ['Eliot Jordan']
|
10
|
+
spec.email = ['eliot.jordan@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'RabbitMQ messaging for Geoblacklight.'
|
13
|
+
spec.description = 'RabbitMQ messaging for Geoblacklight.'
|
14
|
+
spec.homepage = 'https://github.com/eliotjordan/geoblacklight-messaging'
|
15
|
+
spec.license = 'APACHE2'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_dependency 'sneakers'
|
23
|
+
spec.add_dependency 'rails', '>= 4.2.7.1'
|
24
|
+
|
25
|
+
spec.add_development_dependency 'bundler', '~> 1.13'
|
26
|
+
spec.add_development_dependency 'rake'
|
27
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
28
|
+
spec.add_development_dependency 'rspec-rails', '~> 3.5.0'
|
29
|
+
spec.add_development_dependency 'solr_wrapper'
|
30
|
+
spec.add_development_dependency 'engine_cart', '~> 1.0', '>= 1.0.1'
|
31
|
+
spec.add_development_dependency 'geoblacklight', '~> 1.2'
|
32
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module GeoblacklightMessaging
|
4
|
+
class Install < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
|
7
|
+
def install_messaging_config
|
8
|
+
config_file_path = 'config/messaging.yml'
|
9
|
+
initializer_file_path = 'config/initializers/messaging_config.rb'
|
10
|
+
copy_file config_file_path, config_file_path
|
11
|
+
copy_file initializer_file_path, initializer_file_path
|
12
|
+
end
|
13
|
+
|
14
|
+
def install_sneakers
|
15
|
+
config_file_path = 'config/messaging.yml'
|
16
|
+
initializer_file_path = 'config/initializers/messaging_config.rb'
|
17
|
+
copy_file config_file_path, config_file_path
|
18
|
+
copy_file initializer_file_path, initializer_file_path
|
19
|
+
end
|
20
|
+
|
21
|
+
def install_rake_tasks
|
22
|
+
initializer_file_path = 'config/initializers/sneakers.rb'
|
23
|
+
rakefile_path = 'Rakefile'
|
24
|
+
copy_file initializer_file_path, initializer_file_path
|
25
|
+
inject_into_file rakefile_path, before: /Rails.application.load_tasks/ do
|
26
|
+
"require 'sneakers/tasks'\n"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Messaging
|
2
|
+
def config
|
3
|
+
@config ||= config_yaml.with_indifferent_access
|
4
|
+
end
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def config_yaml
|
9
|
+
YAML.load(ERB.new(File.read("#{Rails.root}/config/messaging.yml")).result)[Rails.env]
|
10
|
+
end
|
11
|
+
|
12
|
+
module_function :config, :config_yaml
|
13
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
defaults: &defaults
|
2
|
+
events:
|
3
|
+
server: <%= ENV['RABBIT_SERVER'] || 'amqp://localhost:5672' %>
|
4
|
+
exchange:
|
5
|
+
geoblacklight: 'gbl_events'
|
6
|
+
|
7
|
+
development:
|
8
|
+
<<: *defaults
|
9
|
+
|
10
|
+
test:
|
11
|
+
<<: *defaults
|
12
|
+
|
13
|
+
production:
|
14
|
+
<<: *defaults
|
15
|
+
|
16
|
+
staging:
|
17
|
+
<<: *defaults
|
metadata
ADDED
@@ -0,0 +1,198 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: geoblacklight_messaging
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Eliot Jordan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-09-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sneakers
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 4.2.7.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 4.2.7.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.13'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.13'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec-rails
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 3.5.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 3.5.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: solr_wrapper
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: engine_cart
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.0'
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: 1.0.1
|
121
|
+
type: :development
|
122
|
+
prerelease: false
|
123
|
+
version_requirements: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - "~>"
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '1.0'
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: 1.0.1
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: geoblacklight
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - "~>"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '1.2'
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - "~>"
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '1.2'
|
145
|
+
description: RabbitMQ messaging for Geoblacklight.
|
146
|
+
email:
|
147
|
+
- eliot.jordan@gmail.com
|
148
|
+
executables: []
|
149
|
+
extensions: []
|
150
|
+
extra_rdoc_files: []
|
151
|
+
files:
|
152
|
+
- ".gitignore"
|
153
|
+
- ".rubocop.yml"
|
154
|
+
- ".travis.yml"
|
155
|
+
- Gemfile
|
156
|
+
- LICENSE
|
157
|
+
- README.md
|
158
|
+
- Rakefile
|
159
|
+
- app/services/geoblacklight_messaging/geoblacklight_event_processor.rb
|
160
|
+
- app/services/geoblacklight_messaging/geoblacklight_event_processor/delete_processor.rb
|
161
|
+
- app/services/geoblacklight_messaging/geoblacklight_event_processor/processor.rb
|
162
|
+
- app/services/geoblacklight_messaging/geoblacklight_event_processor/unknown_event.rb
|
163
|
+
- app/services/geoblacklight_messaging/geoblacklight_event_processor/update_processor.rb
|
164
|
+
- app/workers/geoblacklight_messaging/geoblacklight_event_handler.rb
|
165
|
+
- geoblacklight_messaging.gemspec
|
166
|
+
- lib/generators/geoblacklight_messaging/install_generator.rb
|
167
|
+
- lib/generators/geoblacklight_messaging/templates/config/initializers/messaging_config.rb
|
168
|
+
- lib/generators/geoblacklight_messaging/templates/config/initializers/sneakers.rb
|
169
|
+
- lib/generators/geoblacklight_messaging/templates/config/messaging.yml
|
170
|
+
- lib/geoblacklight_messaging.rb
|
171
|
+
- lib/geoblacklight_messaging/engine.rb
|
172
|
+
- lib/geoblacklight_messaging/version.rb
|
173
|
+
- lib/tasks/geoblacklight_messaging_tasks.rake
|
174
|
+
homepage: https://github.com/eliotjordan/geoblacklight-messaging
|
175
|
+
licenses:
|
176
|
+
- APACHE2
|
177
|
+
metadata: {}
|
178
|
+
post_install_message:
|
179
|
+
rdoc_options: []
|
180
|
+
require_paths:
|
181
|
+
- lib
|
182
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - ">="
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0'
|
187
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
|
+
requirements:
|
189
|
+
- - ">="
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
version: '0'
|
192
|
+
requirements: []
|
193
|
+
rubyforge_project:
|
194
|
+
rubygems_version: 2.6.6
|
195
|
+
signing_key:
|
196
|
+
specification_version: 4
|
197
|
+
summary: RabbitMQ messaging for Geoblacklight.
|
198
|
+
test_files: []
|