test-opensearch 0.0.0.20 → 0.0.24

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: e64802826ae07863828975be01dbb8fee1bc0e4d8fef81ad195fe658ede210e0
4
- data.tar.gz: cd18ef4da46e20bd059a3fcf5d9b2791e630e4c37704cc4af17e2480e717113b
3
+ metadata.gz: 735233dd19333067fd99b45dbea9f11e850ffd51fe8f2b1d67314e01c1b1577f
4
+ data.tar.gz: 6f6ffe333f30cfba27e5f88136dea9fc211fdb1f12210d72f9b63700573b7111
5
5
  SHA512:
6
- metadata.gz: d79fbfa7dd1f59e79db7c53e422cf3f6f4ad8d62b09f7b20566cfec33077230971083b2691dbb57b081344005b0ad09200a2916eba1a35628b18d3cbcf039858
7
- data.tar.gz: ade76a78db35219afeb6cba5cd4db1bcfb14470c9a0f7d1daf82d9a7ae065602fcb9577d36f6e81448f456f2e773837ac48f35be70627c761f3dd6f76ba0108c
6
+ metadata.gz: 5ee989c6617a7d5962265b19c1758d566681249f0d91f64c467a0d221e32d37f5f6ffb6215a8ba9f1487bc9df7790d3be2282807191605586544728ec269eed3
7
+ data.tar.gz: 18931258decedc854123c1ae66bcadb3b73595796f7c2ab60fe4ff3597530084da0e74f525d98f26118db9665b33c1007068090d7daa3e2f0774ba4045d8d83d
@@ -322,7 +322,7 @@ retry_max_times 5
322
322
 
323
323
  The parameter needs for how long need to wait (time in seconds) to retry again:
324
324
  `exponential_backoff`: wait in seconds will become large exponentially per failure,
325
- `periodic:` plugin will retry periodically with fixed intervals (configured via retry_wait). The default value is `:periodic`
325
+ `periodic`: plugin will retry periodically with fixed intervals (configured via retry_wait). The default value is `:exponential_backoff`
326
326
  Periodic -> fixed :retry_wait
327
327
  Exponential backoff: k is number of retry times
328
328
  c: constant factor, @retry_wait
@@ -331,7 +331,7 @@ k: times
331
331
  total retry time: c + c * b^1 + (...) + c*b^k = c*b^(k+1) - 1
332
332
 
333
333
  ```
334
- retry_type :periodic
334
+ retry_type exponential_backoff
335
335
  ```
336
336
 
337
337
  ### retry_wait
@@ -360,7 +360,7 @@ retry_max_interval nil
360
360
 
361
361
  ### retry_randomize
362
362
 
363
- The parameter If true, the output plugin will retry after randomized interval not to do burst retries. The default value is `false`
363
+ The parameter If true, the plugin will retry after randomized interval not to do burst retries. The default value is `false`
364
364
 
365
365
  ```
366
366
  retry_randomize false
@@ -3,10 +3,10 @@ $:.push File.expand_path('../lib', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'test-opensearch'
6
- s.version = '0.0.0.20'
7
- s.authors = ['Oleh']
6
+ s.version = '0.0.24'
7
+ s.authors = ['imcotop']
8
8
  s.email = ['imcotop@icloud.com']
9
- s.description = %q{test}
9
+ s.description = %q{Opensearch output plugin for Fluent event collector}
10
10
  s.summary = s.description
11
11
  s.homepage = 'https://github.com/fluent/fluent-plugin-opensearch'
12
12
  s.license = 'Apache-2.0'
@@ -110,7 +110,7 @@ module Fluent::Plugin
110
110
 
111
111
  @timestamp_parser = create_time_parser
112
112
  @backend_options = backend_options
113
- @retry = retry_state(@retry_randomize)
113
+ @retry = nil
114
114
 
115
115
  raise Fluent::ConfigError, "`password` must be present if `user` is present" if @user && @password.nil?
116
116
 
@@ -337,6 +337,23 @@ module Fluent::Plugin
337
337
  return true
338
338
  end
339
339
 
340
+ def update_retry_state(error=nil)
341
+ if error
342
+ unless @retry
343
+ @retry = retry_state(@retry_randomize)
344
+ end
345
+ @retry.step
346
+ #Raise error if the retry limit has been reached
347
+ raise "Hit limit for retries. retry_times: #{@retry.steps}, error: #{error.message}" if @retry.limit?
348
+ #Retry if the limit hasn't been reached
349
+ log.warn("failed to connect or search.", retry_times: @retry.steps, next_retry_time: @retry.next_time.round, error: error.message)
350
+ sleep(@retry.next_time - Time.now)
351
+ else
352
+ log.debug("retry succeeded.") unless @retry.nil?
353
+ @retry = nil unless @retry.nil?
354
+ end
355
+ end
356
+
340
357
  def run
341
358
  return run_slice if @num_slices <= 1
342
359
 
@@ -347,14 +364,8 @@ module Fluent::Plugin
347
364
  run_slice(slice_id)
348
365
  end
349
366
  end
350
- rescue Faraday::ConnectionFailed, OpenSearch::Transport::Transport::Error => e
351
- @retry.step
352
- #Raise error if the retry limit has been reached
353
- raise "Hit limit for retries. retry_times: #{@retry.limit?}, error: #{e.message}" if @retry.limit?
354
-
355
- #Retry if the retry limit hasn't been reached
356
- log.warn("failed to connect or search.", retry_times: @retry.steps, next_retry_time: @retry.next_time.round, error: e.message)
357
- sleep(@retry.next_time - Time.now)
367
+ rescue Faraday::ConnectionFailed, OpenSearch::Transport::Transport::Error => error
368
+ update_retry_state(error)
358
369
  retry
359
370
  end
360
371
 
@@ -376,9 +387,7 @@ module Fluent::Plugin
376
387
 
377
388
  router.emit_stream(@tag, es)
378
389
  clear_scroll(scroll_id)
379
- #reset steps and next_time if our function successful ends
380
- @retry.instance_variable_set(:@steps, 0)
381
- @retry.instance_variable_set(:@next_time, nil)
390
+ update_retry_state
382
391
  end
383
392
 
384
393
  def clear_scroll(scroll_id)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-opensearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0.20
4
+ version: 0.0.24
5
5
  platform: ruby
6
6
  authors:
7
- - Oleh
7
+ - imcotop
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-22 00:00:00.000000000 Z
11
+ date: 2024-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -192,7 +192,7 @@ dependencies:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
194
  version: '2.0'
195
- description: test
195
+ description: Opensearch output plugin for Fluent event collector
196
196
  email:
197
197
  - imcotop@icloud.com
198
198
  executables: []
@@ -272,7 +272,7 @@ requirements: []
272
272
  rubygems_version: 3.5.7
273
273
  signing_key:
274
274
  specification_version: 4
275
- summary: test
275
+ summary: Opensearch output plugin for Fluent event collector
276
276
  test_files:
277
277
  - test/helper.rb
278
278
  - test/plugin/datastream_template.json