surfliner-metadata_consumer 0.1.0.pre.alpha → 0.1.0.pre.alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da6520951750821f9f2de1ed06f02a3d087d497283c2a2107a3f3f40ddcf786f
4
- data.tar.gz: f243e4bda74dcbdfc85c99d77477df1e29d69816e568ba7314aadb96534875c1
3
+ metadata.gz: 22ceb6aaafb75d24e2cf646c3ac55eaca9c0fc92183a448f3ad3a09e9920eaea
4
+ data.tar.gz: 52c43074990eade7d93c32fa471329e845d2776f9229246f57bec81e75fa558d
5
5
  SHA512:
6
- metadata.gz: 49de449388610d4683296ea83021fe4bd7f5c5a2112eb52173c4adb81e8c1bd6e14b17acb2f1e6b4397f6699c973f04b22bc1d2ccfce9a2ea3d05a41d8e92277
7
- data.tar.gz: 5192138d3868a691247adb1777270b23552465b3fe60ed76303f3605b1851d9ce5bff7afd09ea31c2d0da200316f37ea6cc81ef0363aa2c565e5ec45c847aec2
6
+ metadata.gz: f19622750625a84977122fa344b8635bac1d6f80de562237505be22f82aa3acbc532d53f768f0f3b9b7dbda84724d1979b9396e785dca25d30216b71b8746c65
7
+ data.tar.gz: 47621bc83433c05a36cd0d15a3b3a526eb981b0bd1085014c5179ea7c1dce0ad0a12722895873d629bfc1a510cb3648d1a5b2695d1b797d9960befcbb90e517e
data/CHANGES.md ADDED
@@ -0,0 +1,7 @@
1
+ # 0.1.0.pre.alpha.1 (2025-02-12)
2
+
3
+ - CI pipeline gem release test
4
+
5
+ # 0.1.0.pre.alpha (2025-02-12)
6
+
7
+ - Initial release
data/Gemfile CHANGED
@@ -2,5 +2,4 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- # Specify your gem's dependencies in surfliner_schema.gemspec
6
5
  gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- surfliner-metadata_consumer (0.1.0.pre.alpha)
4
+ surfliner-metadata_consumer (0.1.0.pre.alpha.2)
5
5
  bunny (~> 2.23)
6
6
  opentelemetry-exporter-otlp (~> 0.26.3)
7
7
  opentelemetry-instrumentation-all (~> 0.60.0)
@@ -13,7 +13,7 @@ GEM
13
13
  specs:
14
14
  addressable (2.8.7)
15
15
  public_suffix (>= 2.0.2, < 7.0)
16
- amq-protocol (2.3.2)
16
+ amq-protocol (2.3.3)
17
17
  ast (2.4.2)
18
18
  bigdecimal (3.1.9)
19
19
  builder (3.3.0)
@@ -34,7 +34,7 @@ GEM
34
34
  debug (1.9.2)
35
35
  irb (~> 1.10)
36
36
  reline (>= 0.3.8)
37
- diff-lcs (1.5.1)
37
+ diff-lcs (1.6.0)
38
38
  docile (1.4.1)
39
39
  dotenv (2.8.1)
40
40
  faraday (2.12.2)
@@ -44,11 +44,6 @@ GEM
44
44
  faraday-net_http (3.4.0)
45
45
  net-http (>= 0.5.0)
46
46
  google-protobuf (3.25.6)
47
- google-protobuf (3.25.6-aarch64-linux)
48
- google-protobuf (3.25.6-arm64-darwin)
49
- google-protobuf (3.25.6-x86-linux)
50
- google-protobuf (3.25.6-x86_64-darwin)
51
- google-protobuf (3.25.6-x86_64-linux)
52
47
  googleapis-common-protos-types (1.18.0)
53
48
  google-protobuf (>= 3.18, < 5.a)
54
49
  hashdiff (1.1.2)
@@ -57,14 +52,14 @@ GEM
57
52
  pp (>= 0.6.0)
58
53
  rdoc (>= 4.0.0)
59
54
  reline (>= 0.4.2)
60
- json (2.9.1)
55
+ json (2.10.1)
61
56
  language_server-protocol (3.17.0.4)
62
57
  lint_roller (1.1.0)
63
- logger (1.6.5)
58
+ logger (1.6.6)
64
59
  net-http (0.6.0)
65
60
  uri
66
- opentelemetry-api (1.4.0)
67
- opentelemetry-common (0.21.0)
61
+ opentelemetry-api (1.5.0)
62
+ opentelemetry-common (0.22.0)
68
63
  opentelemetry-api (~> 1.0)
69
64
  opentelemetry-exporter-otlp (0.26.3)
70
65
  google-protobuf (~> 3.14)
@@ -250,17 +245,17 @@ GEM
250
245
  opentelemetry-helpers-sql-obfuscation
251
246
  opentelemetry-instrumentation-base (~> 0.22.1)
252
247
  opentelemetry-semantic_conventions (>= 1.8.0)
253
- opentelemetry-registry (0.3.1)
248
+ opentelemetry-registry (0.4.0)
254
249
  opentelemetry-api (~> 1.1)
255
250
  opentelemetry-sdk (1.4.1)
256
251
  opentelemetry-api (~> 1.1)
257
252
  opentelemetry-common (~> 0.20)
258
253
  opentelemetry-registry (~> 0.2)
259
254
  opentelemetry-semantic_conventions
260
- opentelemetry-semantic_conventions (1.10.1)
255
+ opentelemetry-semantic_conventions (1.11.0)
261
256
  opentelemetry-api (~> 1.0)
262
257
  parallel (1.26.3)
263
- parser (3.3.7.0)
258
+ parser (3.3.7.1)
264
259
  ast (~> 2.4.1)
265
260
  racc
266
261
  pp (0.6.2)
@@ -274,12 +269,12 @@ GEM
274
269
  rainbow (3.1.1)
275
270
  rake (13.2.1)
276
271
  rbtree (0.4.6)
277
- rdoc (6.11.0)
272
+ rdoc (6.12.0)
278
273
  psych (>= 4.0.0)
279
274
  regexp_parser (2.10.0)
280
275
  reline (0.6.0)
281
276
  io-console (~> 0.5)
282
- rexml (3.4.0)
277
+ rexml (3.4.1)
283
278
  rsolr (2.6.0)
284
279
  builder (>= 2.1.2)
285
280
  faraday (>= 0.9, < 3, != 2.0.0)
@@ -287,7 +282,7 @@ GEM
287
282
  rspec-core (~> 3.13.0)
288
283
  rspec-expectations (~> 3.13.0)
289
284
  rspec-mocks (~> 3.13.0)
290
- rspec-core (3.13.2)
285
+ rspec-core (3.13.3)
291
286
  rspec-support (~> 3.13.0)
292
287
  rspec-expectations (3.13.3)
293
288
  diff-lcs (>= 1.2.0, < 2.0)
@@ -296,17 +291,17 @@ GEM
296
291
  diff-lcs (>= 1.2.0, < 2.0)
297
292
  rspec-support (~> 3.13.0)
298
293
  rspec-support (3.13.2)
299
- rubocop (1.70.0)
294
+ rubocop (1.71.2)
300
295
  json (~> 2.3)
301
296
  language_server-protocol (>= 3.17.0)
302
297
  parallel (~> 1.10)
303
298
  parser (>= 3.3.0.2)
304
299
  rainbow (>= 2.2.2, < 4.0)
305
300
  regexp_parser (>= 2.9.3, < 3.0)
306
- rubocop-ast (>= 1.36.2, < 2.0)
301
+ rubocop-ast (>= 1.38.0, < 2.0)
307
302
  ruby-progressbar (~> 1.7)
308
303
  unicode-display_width (>= 2.4.0, < 4.0)
309
- rubocop-ast (1.38.0)
304
+ rubocop-ast (1.38.1)
310
305
  parser (>= 3.3.1.0)
311
306
  rubocop-performance (1.23.1)
312
307
  rubocop (>= 1.48.1, < 2.0)
@@ -325,10 +320,10 @@ GEM
325
320
  sorted_set (1.0.3)
326
321
  rbtree
327
322
  set (~> 1.0)
328
- standard (1.44.0)
323
+ standard (1.45.0)
329
324
  language_server-protocol (~> 3.17.0.2)
330
325
  lint_roller (~> 1.0)
331
- rubocop (~> 1.70.0)
326
+ rubocop (~> 1.71.0)
332
327
  standard-custom (~> 1.0.0)
333
328
  standard-performance (~> 1.6)
334
329
  standard-custom (1.0.2)
@@ -337,23 +332,19 @@ GEM
337
332
  standard-performance (1.6.0)
338
333
  lint_roller (~> 1.1)
339
334
  rubocop-performance (~> 1.23.0)
340
- stringio (3.1.2)
335
+ stringio (3.1.5)
341
336
  unicode-display_width (3.1.4)
342
337
  unicode-emoji (~> 4.0, >= 4.0.4)
343
338
  unicode-emoji (4.0.4)
344
- uri (1.0.2)
345
- webmock (3.24.0)
339
+ uri (1.0.3)
340
+ webmock (3.25.0)
346
341
  addressable (>= 2.8.0)
347
342
  crack (>= 0.3.2)
348
343
  hashdiff (>= 0.4.0, < 2.0.0)
349
344
  yard (0.9.37)
350
345
 
351
346
  PLATFORMS
352
- aarch64-linux
353
- arm64-darwin
354
347
  ruby
355
- x86-linux
356
- x86_64-darwin
357
348
  x86_64-linux
358
349
 
359
350
  DEPENDENCIES
@@ -371,4 +362,4 @@ DEPENDENCIES
371
362
  yard (~> 0.9.37)
372
363
 
373
364
  BUNDLED WITH
374
- 2.5.22
365
+ 2.6.2
data/README.md CHANGED
@@ -61,11 +61,11 @@ a configured `SOLR_URL`, e.g.:
61
61
  SOLR_URL=http://admin:admin@solr:8983/solr/daylight-dev
62
62
  ```
63
63
 
64
- The `bin/simulate-publish-event` script expects an `API_BASE_URI`, used to generate resource URLs
64
+ The `bin/simulate-publish-event` script expects an `METADATA_API_URL_BASE`, used to generate resource URLs
65
65
  for provided IDs:
66
66
 
67
67
  ```sh
68
- API_BASE_URI=http://superskunk:3000
68
+ METADATA_API_URL_BASE=http://superskunk:3000/resources
69
69
  ```
70
70
 
71
71
  ## Solr / Daylight handler implementation
@@ -20,4 +20,6 @@ tracer = OpenTelemetry.tracer_provider.tracer("DaylightConsumerTracer")
20
20
 
21
21
  handler = Surfliner::MetadataConsumer::Solr::MessageHandler
22
22
 
23
- Surfliner::MetadataConsumer::Consumer.run(logger:, tracer:, handler:)
23
+ opts = { queue: { durable: false } }
24
+
25
+ Surfliner::MetadataConsumer::Consumer.run(logger:, tracer:, handler:, opts:)
@@ -6,18 +6,20 @@ require "logger"
6
6
 
7
7
  require "surfliner/metadata_consumer/mq_connection"
8
8
 
9
- api_base = ENV.fetch("API_BASE_URI") { "http://example.com/api" }
10
- logger = Logger.new($stdout)
9
+ api_base = ENV.fetch("METADATA_API_URL_BASE") { "http://metadata.test/resources" }
10
+ logger = Logger.new($stdout)
11
11
  logger.level = ENV.fetch("LOG_LEVEL") { Logger::INFO }
12
12
 
13
- connection = Surfliner::MetadataConsumer::MqConnection.new(logger: logger).connect
13
+ opts = { queue: { durable: false } }
14
+
15
+ connection = Surfliner::MetadataConsumer::MqConnection.new(logger:, opts:).connect
14
16
 
15
17
  begin
16
18
  ARGV.each do |id|
17
19
  payload =
18
- {resourceUrl: "#{api_base}/resources/#{id}",
19
- status: :published,
20
- time_stamp: DateTime.now}.to_json
20
+ { resourceUrl: "#{api_base}/#{id}",
21
+ status: :published,
22
+ time_stamp: DateTime.now }.to_json
21
23
 
22
24
  logger.info "Publishing to #{connection.routing_key} with #{payload}"
23
25
  connection.exchange.publish(payload, routing_key: connection.routing_key)
@@ -13,8 +13,9 @@ module Surfliner
13
13
  # @param tracer [OpenTelemetry::Trace::Tracer] OpenTelemetry tracer
14
14
  # @param logger [Logger] log message destination
15
15
  # @param handler #handle an object accepting a JSON string
16
- def initialize(tracer:, logger:, handler:)
17
- @connection = MqConnection.new(logger:)
16
+ # @param opts [Hash] (see MqConnection#new)
17
+ def initialize(tracer:, logger:, handler:, opts: nil)
18
+ @connection = MqConnection.new(logger:, opts:)
18
19
  @logger = logger
19
20
  @tracer = tracer
20
21
  @handler = handler
@@ -24,8 +25,9 @@ module Surfliner
24
25
  # @param tracer [OpenTelemetry::Trace::Tracer] OpenTelemetry tracer
25
26
  # @param logger [Logger] log message destination
26
27
  # @param handler #handle an object accepting a JSON string payload
27
- def self.run(tracer:, logger:, handler:)
28
- new(tracer:, logger:, handler:).run
28
+ # @param opts [Hash] (see MqConnection#new)
29
+ def self.run(tracer:, logger:, handler:, opts: nil)
30
+ new(tracer:, logger:, handler:, opts:).run
29
31
  end
30
32
 
31
33
  # Starts listening to the message queue and passing messages to the handler.
@@ -4,6 +4,15 @@ module Surfliner
4
4
  module MetadataConsumer
5
5
  # An object encapsulating a RabbitMQ connection.
6
6
  class MqConnection
7
+ # Default RabbitMQ topic options
8
+ DEFAULT_TOPIC_OPTS = {auto_delete: true}.freeze
9
+
10
+ # Default RabbitMQ queue options
11
+ DEFAULT_QUEUE_OPTS = {durable: true}.freeze
12
+
13
+ # Default RabbitMQ topic and queue options
14
+ DEFAULT_OPTS = {topic: DEFAULT_TOPIC_OPTS, queue: DEFAULT_QUEUE_OPTS}.freeze
15
+
7
16
  # @return [Logger] The logger
8
17
  attr_reader :logger
9
18
 
@@ -22,13 +31,18 @@ module Surfliner
22
31
  # @return [MqConfig] The configuration
23
32
  attr_reader :config
24
33
 
34
+ # @return [Hash<Symbol, Hash>] Options to pass when connecting to RabbitMQ topic and queue. Overrides DEFAULT_OPTS.
35
+ attr_reader :opts
36
+
25
37
  # Initializes a new `MqConnection`.
26
38
  #
27
39
  # @param logger [Logger] the logger
28
40
  # @param config [MqConfig] the configuration
29
- def initialize(logger:, config: MqConfig.from_env)
41
+ # @param opts [Hash<Symbol, Hash>] Options to pass when connecting to RabbitMQ topic and queue. Overrides DEFAULT_OPTS.
42
+ def initialize(logger:, config: MqConfig.from_env, opts: nil)
30
43
  @logger = logger
31
44
  @config = config
45
+ @opts = merge_opts(opts)
32
46
  end
33
47
 
34
48
  # Opens a connection.
@@ -41,8 +55,8 @@ module Surfliner
41
55
  @connection = Bunny.new(config.connection_url, logger: logger)
42
56
  connect_on(connection)
43
57
  @channel = connection.create_channel
44
- @exchange = channel.topic(config.topic, auto_delete: true)
45
- @queue = channel.queue(config.queue_name, durable: true)
58
+ @exchange = channel.topic(config.topic, topic_opts)
59
+ @queue = channel.queue(config.queue_name, queue_opts)
46
60
  queue.bind(exchange, routing_key: config.routing_key)
47
61
 
48
62
  self
@@ -68,8 +82,12 @@ module Surfliner
68
82
 
69
83
  # Closes the connection.
70
84
  def close
71
- channel&.close
85
+ return unless channel
86
+ return if channel.closed?
87
+ logger.info("closing channel")
88
+ channel.close
72
89
  ensure
90
+ logger.info("closing connection")
73
91
  connection&.close
74
92
  end
75
93
 
@@ -93,8 +111,28 @@ module Surfliner
93
111
  config.port
94
112
  end
95
113
 
114
+ # @return [Hash] Options passed when connecting to RabbitMQ topic
115
+ def topic_opts
116
+ opts[:topic]
117
+ end
118
+
119
+ # @return [Hash] Options passed when connecting to RabbitMQ queue
120
+ def queue_opts
121
+ opts[:queue]
122
+ end
123
+
96
124
  private
97
125
 
126
+ def merge_opts(opts)
127
+ DEFAULT_OPTS.to_h do |opt_type, opts_default|
128
+ opts_actual = opts_default.dup
129
+ if opts && (opts_provided = opts[opt_type])
130
+ opts_actual.merge!(opts_provided)
131
+ end
132
+ [opt_type, opts_actual]
133
+ end
134
+ end
135
+
98
136
  def connect_on(connection, timeout = 120)
99
137
  timer = 0
100
138
  logger.info "Trying to open queue connection with timeout=#{timeout}"
@@ -3,6 +3,6 @@ module Surfliner
3
3
  # Parent module for this gem
4
4
  module MetadataConsumer
5
5
  # The gem version
6
- VERSION = "0.1.0.pre.alpha"
6
+ VERSION = "0.1.0.pre.alpha.2"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: surfliner-metadata_consumer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.alpha
4
+ version: 0.1.0.pre.alpha.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Project Surfliner
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-02-12 00:00:00.000000000 Z
10
+ date: 2025-03-07 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: bunny
@@ -240,19 +239,17 @@ dependencies:
240
239
  - - "~>"
241
240
  - !ruby/object:Gem::Version
242
241
  version: 0.9.37
243
- description:
244
- email:
245
242
  executables:
246
243
  - daylight-index-listen
247
244
  - simulate-publish-event
248
245
  extensions: []
249
246
  extra_rdoc_files: []
250
247
  files:
248
+ - CHANGES.md
251
249
  - Dockerfile
252
250
  - Gemfile
253
251
  - Gemfile.lock
254
252
  - LICENSE
255
- - LICENSE~
256
253
  - README.md
257
254
  - Rakefile
258
255
  - bin/daylight-index-listen
@@ -268,7 +265,6 @@ files:
268
265
  - lib/surfliner/metadata_consumer/solr/message_handler.rb
269
266
  - lib/surfliner/metadata_consumer/superskunk_client.rb
270
267
  - lib/surfliner/metadata_consumer/version.rb
271
- - surfliner-metadata_consumer.gemspec
272
268
  homepage: https://gitlab.com/surfliner/metadata_consumer
273
269
  licenses:
274
270
  - MIT
@@ -276,7 +272,6 @@ metadata:
276
272
  homepage_uri: https://gitlab.com/surfliner/metadata_consumer
277
273
  source_code_uri: https://gitlab.com/surfliner/metadata_consumer.git
278
274
  rubygems_mfa_required: 'false'
279
- post_install_message:
280
275
  rdoc_options: []
281
276
  require_paths:
282
277
  - lib
@@ -291,8 +286,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
291
286
  - !ruby/object:Gem::Version
292
287
  version: '0'
293
288
  requirements: []
294
- rubygems_version: 3.5.22
295
- signing_key:
289
+ rubygems_version: 3.6.2
296
290
  specification_version: 4
297
291
  summary: Surfliner metadata consumer
298
292
  test_files: []
data/LICENSE~ DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2019 The Regents of the University of California.
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,42 +0,0 @@
1
- require_relative "lib/surfliner/metadata_consumer/version"
2
-
3
- Gem::Specification.new do |spec|
4
- spec.name = "surfliner-metadata_consumer"
5
- spec.version = Surfliner::MetadataConsumer::VERSION
6
- spec.authors = ["Project Surfliner"]
7
-
8
- spec.homepage = "https://gitlab.com/surfliner/metadata_consumer"
9
- spec.license = "MIT"
10
- spec.summary = "Surfliner metadata consumer"
11
-
12
- spec.required_ruby_version = Gem::Requirement.new(">= 3.3.1")
13
-
14
- spec.metadata["homepage_uri"] = spec.homepage
15
- spec.metadata["source_code_uri"] = "https://gitlab.com/surfliner/metadata_consumer.git"
16
- spec.metadata["rubygems_mfa_required"] = "false"
17
-
18
- spec.files = Dir["lib/**/*.rb"] + Dir["bin/*"] + Dir["[A-Z]*"]
19
-
20
- ["daylight-index-listen", "simulate-publish-event"].each do |script|
21
- spec.executables << script
22
- end
23
-
24
- spec.add_dependency "bunny", "~> 2.23"
25
- # TODO: Figure out why we get "The otlp exporter cannot be configured - please add opentelemetry-exporter-otlp to your Gemfile"
26
- spec.add_dependency "opentelemetry-exporter-otlp", "~> 0.26.3"
27
- spec.add_dependency "opentelemetry-instrumentation-all", "~> 0.60.0"
28
- spec.add_dependency "opentelemetry-sdk", "~> 1.4.1"
29
- spec.add_dependency "rsolr", ">= 1.0", "< 3"
30
-
31
- spec.add_development_dependency "debug", "~> 1.9.2"
32
- spec.add_development_dependency "rspec", "~> 3.13"
33
- spec.add_development_dependency "standard", "~> 1.31"
34
- spec.add_development_dependency "ci_reporter_rspec", "~> 1.0"
35
- spec.add_development_dependency "colorize", "~> 0.8"
36
- spec.add_development_dependency "dotenv", "~> 2.7"
37
- spec.add_development_dependency "rake", "~> 13.0"
38
- spec.add_development_dependency "simplecov", "~> 0.22"
39
- spec.add_development_dependency "simplecov-cobertura", "~> 2.1"
40
- spec.add_development_dependency "webmock", "~> 3.12"
41
- spec.add_development_dependency "yard", "~> 0.9.37"
42
- end