surfliner-metadata_consumer 0.1.0.pre.alpha.4 → 0.1.0.pre.alpha.6

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.
@@ -0,0 +1,135 @@
1
+ require "bunny"
2
+ require "surfliner/util/assert"
3
+
4
+ module Surfliner
5
+ module Mq
6
+ # An object encapsulating a RabbitMQ connection.
7
+ class Connection
8
+ include Util::Assert
9
+
10
+ # @return [Logger] The logger
11
+ attr_reader :logger
12
+
13
+ # @return [Bunny::Session] The current RabbitMQ session
14
+ attr_reader :session
15
+
16
+ # @return [Bunny::Channel] The channel being listened to
17
+ attr_reader :channel
18
+
19
+ # @return [ConnectionConfig] The configuration
20
+ attr_reader :config
21
+
22
+ # Initializes a new `MqConnection`.
23
+ #
24
+ # @param logger [Logger] the logger
25
+ # @param config [ConnectionConfig] the configuration
26
+ def initialize(logger:, config: ConnectionConfig.from_env)
27
+ @logger = not_nil!(logger)
28
+ @config = not_nil!(config)
29
+ end
30
+
31
+ # Opens this connection and creates a channel. If a block is
32
+ # given, yields the open connection, closing the connection and
33
+ # channel afterwards; otherwise, returns the open connection.
34
+ # @return [self] an open connection
35
+ # @yieldparam connection [self] an open connection
36
+ # @raise [IOError] if already connected
37
+ def connect
38
+ init_connection
39
+
40
+ return self unless block_given?
41
+
42
+ begin
43
+ yield self
44
+ ensure
45
+ close
46
+ end
47
+ end
48
+
49
+ # Opens a session, yields a client for the specified topic, and closes the
50
+ # session after the provided block completes.
51
+ # @param config [TopicConfig] topic configuration
52
+ # @yield [MqTopic] A client for the topic
53
+ def with_topic(config = TopicConfig.from_env)
54
+ connect do |cxn|
55
+ yield cxn.topic_from(config)
56
+ end
57
+ end
58
+
59
+ # Returns a client for the specified topic. Note that this does _not_ open
60
+ # or close the connection.
61
+ #
62
+ # @param config [TopicConfig] topic configuration
63
+ # @return [Topic] A client for the topic
64
+ # @raise [IOError] if the connection is not open
65
+ def topic_from(config)
66
+ raise IOError, "RabbitMQ session not open" unless open?
67
+
68
+ Topic.from_config(config, channel:, logger:)
69
+ end
70
+
71
+ # Closes the session.
72
+ def close
73
+ logger.info("closing session")
74
+ # Note: This will also close any open channels
75
+ session&.close(config.await_response_on_close)
76
+ end
77
+
78
+ # @return [true, false] True if the session is open, false otherwise
79
+ def open?
80
+ session&.status == :open
81
+ end
82
+
83
+ # @return [Symbol, nil] The session status, or nil if there is no session
84
+ def status
85
+ session&.status
86
+ end
87
+
88
+ # @return [String] The RabbitMQ hostname
89
+ def host
90
+ config.host
91
+ end
92
+
93
+ # @return [String] The RabbitMQ port
94
+ def port
95
+ config.port
96
+ end
97
+
98
+ private
99
+
100
+ def init_connection
101
+ raise IOError, "RabbitMQ session #{session} already open." if open?
102
+
103
+ logger.info("Rabbitmq message broker session url: #{config.redacted_url}")
104
+ opts = {logger:}.merge(config.opts)
105
+ @session = Bunny.new(config.session_url, **opts)
106
+ connect_on(session)
107
+ @channel = session.create_channel
108
+ rescue Bunny::TCPConnectionFailed => err
109
+ # TODO: realistically, this only happens in session.start, where we're eating it
110
+ logger.error("Connection to #{config.redacted_url} failed")
111
+ raise err
112
+ rescue Bunny::PossibleAuthenticationFailureError => err
113
+ # TODO: realistically, this only happens in session.start, where we're eating it
114
+ logger.error("Failed to authenticate to #{config.redacted_url}")
115
+ raise err
116
+ end
117
+
118
+ def connect_on(session, timeout = 120)
119
+ timer = 0
120
+ logger.info "Trying to open queue session with timeout=#{timeout}"
121
+ while timer < timeout
122
+ begin
123
+ session.start
124
+ rescue
125
+ # TODO: do we actually want to rescue from everything?
126
+ end
127
+ return session if session.status == :open
128
+ sleep 1
129
+ timer += 1
130
+ end
131
+ raise "Failed to connect to queue."
132
+ end
133
+ end
134
+ end
135
+ end
@@ -0,0 +1,83 @@
1
+ module Surfliner
2
+ module Mq
3
+ # An object encapsulating RabbitMQ configuration.
4
+ class ConnectionConfig
5
+ FALSE_VALUES = ([""] + %w[0 off Off OFF f false False FALSE F n no No NO N]).freeze
6
+
7
+ # @return [String] The RabbitMQ hostname
8
+ attr_reader :host
9
+
10
+ # @return [String] The RabbitMQ AMQP port
11
+ attr_reader :port
12
+
13
+ # @return [String] The RabbitMQ username
14
+ attr_reader :username
15
+
16
+ # @return [String] The RabbitMQ passsword
17
+ attr_reader :password
18
+
19
+ # @return [Boolean] whether the RabbitMQ client should wait for a response when closing the connection
20
+ attr_reader :await_response_on_close
21
+
22
+ # @return [Hash] Additional RabbitMQ connection options (see Bunny::Session#initialize)
23
+ attr_reader :opts
24
+
25
+ # Initializes a new `MqConfig` object.
26
+ # @param host [String] RabbitMQ hostname
27
+ # @param port [String] RabbitMQ AMQP port
28
+ # @param username [String] RabbitMQ username
29
+ # @param password [String] RabbitMQ passsword
30
+ # @param await_response_on_close [Boolean] whether the RabbitMQ client should wait for a response when closing the connection
31
+ # @param opts [Hash] additional RabbitMQ conection options (see Bunny::Session#initialize)
32
+ def initialize(host:, port:, username:, password:, await_response_on_close: true, **opts)
33
+ @host = host
34
+ @port = port
35
+ @username = username
36
+ @password = password
37
+ @await_response_on_close = parse_boolean(await_response_on_close)
38
+ @opts = opts
39
+ end
40
+
41
+ class << self
42
+ # Reads RabbitMQ configuration from environment variables and
43
+ # returns it as a new `ConnectionConfig` object.
44
+ #
45
+ # | Variable | Sample value | Description |
46
+ # |-----------------------------|--------------|-----------------------------------------------------------|
47
+ # | `RABBITMQ_HOST` | `rabbitmq` | Hostname of RabbitMQ server |
48
+ # | `RABBITMQ_NODE_PORT_NUMBER` | `5672` | Port name of RabbitMQ server |
49
+ # | `RABBITMQ_USERNAME` | `user` | RabbitMQ username |
50
+ # | `RABBITMQ_PASSWORD` | `bitnami` | RabbitMQ password |
51
+ # | `RABBITMQ_AWAIT_ON_CLOSE` | `false` | Whether to wait on response when closing (default = true) |
52
+ #
53
+ # @return [ConnectionConfig] The configuration.
54
+ def from_env(**opts)
55
+ ConnectionConfig.new(
56
+ host: ENV.fetch("RABBITMQ_HOST"),
57
+ port: ENV.fetch("RABBITMQ_NODE_PORT_NUMBER"),
58
+ username: ENV.fetch("RABBITMQ_USERNAME"),
59
+ password: ENV.fetch("RABBITMQ_PASSWORD"),
60
+ await_response_on_close: ENV.fetch("RABBITMQ_AWAIT_ON_CLOSE") || true,
61
+ **opts
62
+ )
63
+ end
64
+ end
65
+
66
+ # @return [String] the connection URL as a string
67
+ def session_url
68
+ @session_url ||= "amqp://#{username}:#{password}@#{host}:#{port}"
69
+ end
70
+
71
+ # @return [String] the connection URL as a string, without the password
72
+ def redacted_url
73
+ @redacted_url ||= session_url.sub(password, "REDACTED")
74
+ end
75
+
76
+ private
77
+
78
+ def parse_boolean(v)
79
+ !FALSE_VALUES.include?(v.to_s)
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,49 @@
1
+ module Surfliner
2
+ module Mq
3
+ # Encapsulates queue configuration
4
+ class QueueConfig
5
+ # @return [String] The queue to listen to
6
+ attr_reader :name
7
+
8
+ # @return [String] platform routing key to listen to
9
+ attr_reader :routing_key
10
+
11
+ # @return [Hash] RabbitMQ queue options. (See Bunny::Channel#queue)
12
+ attr_reader :options
13
+
14
+ # @param name [String] queue exchange to listen to
15
+ # @param routing_key [String] platform routing key to listen to
16
+ # @param options [Hash] RabbitMQ queue options. (See Bunny::Channel#queue)
17
+ def initialize(name:, routing_key:, options: {})
18
+ @name = name
19
+ @routing_key = routing_key
20
+ @options = options
21
+ end
22
+
23
+ class << self
24
+ # Returns a default (environment-variable-based) configuration with the
25
+ # specified options.
26
+ #
27
+ # | Variable | Sample value | Description |
28
+ # |---------------------------------|-------------------------------|----------------------|
29
+ # | `RABBITMQ_QUEUE` | `surfliner.metadata` | RabbitMQ queue name |
30
+ # | `RABBITMQ_PLATFORM_ROUTING_KEY` | `surfliner.metadata.daylight` | RabbitMQ routing key |
31
+ #
32
+ # @param options [Hash] RabbitMQ queue options. (See Bunny::Channel#queue)
33
+ # @return [QueueConfig] The configuration.
34
+ def from_env(**options)
35
+ QueueConfig.new(
36
+ name: ENV.fetch("RABBITMQ_QUEUE"),
37
+ routing_key: default_routing_key,
38
+ options:
39
+ )
40
+ end
41
+
42
+ # @return [String] The default routing key from `ENV["RABBITMQ_PLATFORM_ROUTING_KEY"]`
43
+ def default_routing_key
44
+ ENV.fetch("RABBITMQ_PLATFORM_ROUTING_KEY")
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,65 @@
1
+ require "surfliner/util/assert"
2
+
3
+ module Surfliner
4
+ module Mq
5
+ # Encapsulates a RabbitMQ topic
6
+ class Topic
7
+ include Surfliner::Util::Assert
8
+
9
+ # @return [String] The name of the topic
10
+ attr_reader :name
11
+
12
+ # @return [Bunny::Channel] The channel being used
13
+ attr_reader :channel
14
+
15
+ # @return [Logger] The logger
16
+ attr_reader :logger
17
+
18
+ # @return [Hash] RabbitMQ topic options. (See Bunny::Channel#topic)
19
+ attr_reader :options
20
+
21
+ # @param name [String] The name of the topic
22
+ # @param channel [Bunny::Channel] The channel to use
23
+ # @param logger [Logger] the logger
24
+ # @param options [Hash] RabbitMQ topic options. (See Bunny::Channel#topic)
25
+ def initialize(name, channel:, logger:, options: {})
26
+ @name = not_nil!(name, "topic name")
27
+ @channel = not_nil!(channel, "channel")
28
+ @logger = not_nil!(logger, "logger")
29
+ @options = not_nil!(options, "options")
30
+ end
31
+
32
+ # @return [Bunny::Exchange] The exchange for the topic
33
+ def exchange
34
+ @exchange ||= channel.topic(name, options)
35
+ end
36
+
37
+ # Publishes the specified payload
38
+ # @param payload [String] the payload to publish
39
+ # @param routing_key [String] platform routing key to publish to
40
+ # @return [Bunny::Exchange] see #exchange
41
+ def publish(payload, routing_key: QueueConfig.default_routing_key)
42
+ logger.info "Publishing to #{routing_key} with payload: #{payload}"
43
+ exchange.publish(payload, routing_key:)
44
+ end
45
+
46
+ # @param config [QueueConfig] queue configuration
47
+ # @return [Bunny::Queue] the queue
48
+ def bind_queue(config = QueueConfig.from_env)
49
+ channel.queue(config.name, config.options).tap do |q|
50
+ q.bind(exchange, routing_key: config.routing_key)
51
+ end
52
+ end
53
+
54
+ class << self
55
+ # Creates a new `MqTopic` from the specified configuration
56
+ # @param config [TopicConfig] the configuration
57
+ # @param channel [Bunny::Channel] The channel to use
58
+ # @param logger [Logger] the logger
59
+ def from_config(config, channel:, logger:)
60
+ new(config.name, channel:, logger:, options: config.options)
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,37 @@
1
+ module Surfliner
2
+ module Mq
3
+ # Encapsulates topic configuration
4
+ class TopicConfig
5
+ # @return [String] The topic exchange to listen to
6
+ attr_reader :name
7
+
8
+ # @return [Hash] RabbitMQ topic options. (See Bunny::Channel#topic)
9
+ attr_reader :options
10
+
11
+ # @param name [String] topic exchange to listen to
12
+ # @param options [Hash] RabbitMQ topic options. (See Bunny::Channel#topic)
13
+ def initialize(name:, options: {})
14
+ @name = name
15
+ @options = options
16
+ end
17
+
18
+ class << self
19
+ # Returns a default (environment-variable-based) configuration with the
20
+ # specified options.
21
+ #
22
+ # | Variable | Sample value | Description |
23
+ # |------------------|----------------------|---------------------|
24
+ # | `RABBITMQ_TOPIC` | `surfliner.metadata` | RabbitMQ topic name |
25
+ #
26
+ # @param options [Hash] RabbitMQ topic options. (See Bunny::Channel#topic)
27
+ # @return [TopicConfig] The configuration.
28
+ def from_env(**options)
29
+ TopicConfig.new(
30
+ name: ENV.fetch("RABBITMQ_TOPIC"),
31
+ options:
32
+ )
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,4 @@
1
+ Dir.glob(File.expand_path("mq/*.rb", __dir__)).each(&method(:require))
2
+
3
+ # General RabbitMQ functionality
4
+ module Surfliner::Mq; end
@@ -0,0 +1,21 @@
1
+ module Surfliner
2
+ # Miscellaneous utility module
3
+ module Util
4
+ # Helper methods for argument validation
5
+ module Assert
6
+ class << self
7
+ include Assert
8
+ end
9
+
10
+ # @param arg_value [Object, nil] the argument value
11
+ # @param arg_name [String] the name of the argument, for error messages
12
+ # @return arg_value
13
+ # @raise [ArgumentError] if `arg_value` is `nil`
14
+ def not_nil!(arg_value, arg_name = "argument")
15
+ return arg_value unless arg_value.nil?
16
+
17
+ raise ArgumentError, "#{arg_name} must not be nil"
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,4 @@
1
+ Dir.glob(File.expand_path("util/*.rb", __dir__)).each(&method(:require))
2
+
3
+ # Miscellaneous utility module
4
+ module Surfliner::Util; end
metadata CHANGED
@@ -1,13 +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
4
+ version: 0.1.0.pre.alpha.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Project Surfliner
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-03-17 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: bunny
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: '2.23'
18
+ version: '2.24'
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
- version: '2.23'
25
+ version: '2.24'
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: opentelemetry-exporter-otlp
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -86,103 +86,117 @@ dependencies:
86
86
  - !ruby/object:Gem::Version
87
87
  version: '3'
88
88
  - !ruby/object:Gem::Dependency
89
- name: debug
89
+ name: ci_reporter_rspec
90
90
  requirement: !ruby/object:Gem::Requirement
91
91
  requirements:
92
92
  - - "~>"
93
93
  - !ruby/object:Gem::Version
94
- version: 1.9.2
94
+ version: '1.0'
95
95
  type: :development
96
96
  prerelease: false
97
97
  version_requirements: !ruby/object:Gem::Requirement
98
98
  requirements:
99
99
  - - "~>"
100
100
  - !ruby/object:Gem::Version
101
- version: 1.9.2
101
+ version: '1.0'
102
102
  - !ruby/object:Gem::Dependency
103
- name: rspec
103
+ name: colorize
104
104
  requirement: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - "~>"
107
107
  - !ruby/object:Gem::Version
108
- version: '3.13'
108
+ version: '0.8'
109
109
  type: :development
110
110
  prerelease: false
111
111
  version_requirements: !ruby/object:Gem::Requirement
112
112
  requirements:
113
113
  - - "~>"
114
114
  - !ruby/object:Gem::Version
115
- version: '3.13'
115
+ version: '0.8'
116
116
  - !ruby/object:Gem::Dependency
117
- name: standard
117
+ name: debug
118
118
  requirement: !ruby/object:Gem::Requirement
119
119
  requirements:
120
120
  - - "~>"
121
121
  - !ruby/object:Gem::Version
122
- version: '1.31'
122
+ version: 1.9.2
123
123
  type: :development
124
124
  prerelease: false
125
125
  version_requirements: !ruby/object:Gem::Requirement
126
126
  requirements:
127
127
  - - "~>"
128
128
  - !ruby/object:Gem::Version
129
- version: '1.31'
129
+ version: 1.9.2
130
130
  - !ruby/object:Gem::Dependency
131
- name: ci_reporter_rspec
131
+ name: dotenv
132
132
  requirement: !ruby/object:Gem::Requirement
133
133
  requirements:
134
134
  - - "~>"
135
135
  - !ruby/object:Gem::Version
136
- version: '1.0'
136
+ version: '2.7'
137
137
  type: :development
138
138
  prerelease: false
139
139
  version_requirements: !ruby/object:Gem::Requirement
140
140
  requirements:
141
141
  - - "~>"
142
142
  - !ruby/object:Gem::Version
143
- version: '1.0'
143
+ version: '2.7'
144
144
  - !ruby/object:Gem::Dependency
145
- name: colorize
145
+ name: github-markup
146
146
  requirement: !ruby/object:Gem::Requirement
147
147
  requirements:
148
148
  - - "~>"
149
149
  - !ruby/object:Gem::Version
150
- version: '0.8'
150
+ version: '5.0'
151
151
  type: :development
152
152
  prerelease: false
153
153
  version_requirements: !ruby/object:Gem::Requirement
154
154
  requirements:
155
155
  - - "~>"
156
156
  - !ruby/object:Gem::Version
157
- version: '0.8'
157
+ version: '5.0'
158
158
  - !ruby/object:Gem::Dependency
159
- name: dotenv
159
+ name: rake
160
160
  requirement: !ruby/object:Gem::Requirement
161
161
  requirements:
162
162
  - - "~>"
163
163
  - !ruby/object:Gem::Version
164
- version: '2.7'
164
+ version: '13.0'
165
165
  type: :development
166
166
  prerelease: false
167
167
  version_requirements: !ruby/object:Gem::Requirement
168
168
  requirements:
169
169
  - - "~>"
170
170
  - !ruby/object:Gem::Version
171
- version: '2.7'
171
+ version: '13.0'
172
172
  - !ruby/object:Gem::Dependency
173
- name: rake
173
+ name: redcarpet
174
174
  requirement: !ruby/object:Gem::Requirement
175
175
  requirements:
176
176
  - - "~>"
177
177
  - !ruby/object:Gem::Version
178
- version: '13.0'
178
+ version: '3.6'
179
179
  type: :development
180
180
  prerelease: false
181
181
  version_requirements: !ruby/object:Gem::Requirement
182
182
  requirements:
183
183
  - - "~>"
184
184
  - !ruby/object:Gem::Version
185
- version: '13.0'
185
+ version: '3.6'
186
+ - !ruby/object:Gem::Dependency
187
+ name: rspec
188
+ requirement: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - "~>"
191
+ - !ruby/object:Gem::Version
192
+ version: '3.13'
193
+ type: :development
194
+ prerelease: false
195
+ version_requirements: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - "~>"
198
+ - !ruby/object:Gem::Version
199
+ version: '3.13'
186
200
  - !ruby/object:Gem::Dependency
187
201
  name: simplecov
188
202
  requirement: !ruby/object:Gem::Requirement
@@ -211,6 +225,20 @@ dependencies:
211
225
  - - "~>"
212
226
  - !ruby/object:Gem::Version
213
227
  version: '2.1'
228
+ - !ruby/object:Gem::Dependency
229
+ name: standard
230
+ requirement: !ruby/object:Gem::Requirement
231
+ requirements:
232
+ - - "~>"
233
+ - !ruby/object:Gem::Version
234
+ version: '1.31'
235
+ type: :development
236
+ prerelease: false
237
+ version_requirements: !ruby/object:Gem::Requirement
238
+ requirements:
239
+ - - "~>"
240
+ - !ruby/object:Gem::Version
241
+ version: '1.31'
214
242
  - !ruby/object:Gem::Dependency
215
243
  name: webmock
216
244
  requirement: !ruby/object:Gem::Requirement
@@ -240,7 +268,7 @@ dependencies:
240
268
  - !ruby/object:Gem::Version
241
269
  version: 0.9.37
242
270
  executables:
243
- - daylight-index-listen
271
+ - index-on-publish
244
272
  - simulate-publish-event
245
273
  extensions: []
246
274
  extra_rdoc_files: []
@@ -252,12 +280,10 @@ files:
252
280
  - LICENSE
253
281
  - README.md
254
282
  - Rakefile
255
- - bin/daylight-index-listen
283
+ - bin/index-on-publish
256
284
  - bin/simulate-publish-event
257
285
  - lib/surfliner/metadata_consumer.rb
258
286
  - lib/surfliner/metadata_consumer/consumer.rb
259
- - lib/surfliner/metadata_consumer/mq_config.rb
260
- - lib/surfliner/metadata_consumer/mq_connection.rb
261
287
  - lib/surfliner/metadata_consumer/payload.rb
262
288
  - lib/surfliner/metadata_consumer/solr.rb
263
289
  - lib/surfliner/metadata_consumer/solr/delete_handler.rb
@@ -265,6 +291,14 @@ files:
265
291
  - lib/surfliner/metadata_consumer/solr/message_handler.rb
266
292
  - lib/surfliner/metadata_consumer/superskunk_client.rb
267
293
  - lib/surfliner/metadata_consumer/version.rb
294
+ - lib/surfliner/mq.rb
295
+ - lib/surfliner/mq/connection.rb
296
+ - lib/surfliner/mq/connection_config.rb
297
+ - lib/surfliner/mq/queue_config.rb
298
+ - lib/surfliner/mq/topic.rb
299
+ - lib/surfliner/mq/topic_config.rb
300
+ - lib/surfliner/util.rb
301
+ - lib/surfliner/util/assert.rb
268
302
  homepage: https://gitlab.com/surfliner/metadata_consumer
269
303
  licenses:
270
304
  - MIT
@@ -286,7 +320,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
286
320
  - !ruby/object:Gem::Version
287
321
  version: '0'
288
322
  requirements: []
289
- rubygems_version: 3.6.2
323
+ rubygems_version: 3.6.7
290
324
  specification_version: 4
291
325
  summary: Surfliner metadata consumer
292
326
  test_files: []
@@ -1,23 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require "bundler/setup"
3
- require "logger"
4
- require "opentelemetry/sdk"
5
-
6
- require "surfliner/metadata_consumer"
7
-
8
- unless ENV["OTEL_SDK_DISABLED"] == "true"
9
- OpenTelemetry::SDK.configure do |c|
10
- c.service_name = "surfliner-daylight-consumer"
11
- c.use_all # enables auto instrumentation for Bunny, Net::HTTP, etc...
12
- end
13
- end
14
- tracer = OpenTelemetry.tracer_provider.tracer("DaylightConsumerTracer")
15
-
16
- $stdout.sync = true # don't buffer log output
17
- logger = Logger.new($stdout).tap do |logger|
18
- logger.level = ENV.fetch("LOG_LEVEL", Logger::INFO)
19
- end
20
-
21
- handler = Surfliner::MetadataConsumer::Solr::MessageHandler
22
- consumer = Surfliner::MetadataConsumer::Consumer.new(tracer:, logger:, handler:)
23
- consumer.run