influxdb-client 1.8.0.pre.1218 → 1.9.0.pre.1301
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -1
- data/CHANGELOG.md +7 -1
- data/README.md +2 -1
- data/bin/influxdb-restart.sh +1 -1
- data/lib/influxdb2/client/version.rb +1 -1
- data/lib/influxdb2/client/worker.rb +2 -2
- data/lib/influxdb2/client/write_api.rb +5 -2
- data/test/influxdb/delete_api_integration_test.rb +4 -0
- data/test/influxdb/write_api_batching_test.rb +109 -60
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d671be12047966afd88d59cf5d96f5422e1154bbd4d7698329fa90c4f382ed4
|
4
|
+
data.tar.gz: 93bc78686d5bdf9eedd526969e73d87a0356ea1ba9e21073e525f4ab6a956adf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3425542284cf56e6c3531697bbe0edcdb24eab9e0fb2b90f675555eeaadac45c7edc316646bf72cf181383bad23ee3eae03c27078ff5f2048586d93fa12647d
|
7
|
+
data.tar.gz: 6ad395bd8498e81231b61701d8cb2c86aa268638a1c31ac50189aa6b7219d8f9466dbd79ff78242259bb4369c890951ef73b41de5611f41a0baa8aeb2cb9dc92
|
data/.circleci/config.yml
CHANGED
@@ -78,7 +78,7 @@ jobs:
|
|
78
78
|
default: &default-ruby-image "circleci/ruby:2.6-stretch"
|
79
79
|
influxdb-image:
|
80
80
|
type: string
|
81
|
-
default: &default-influxdb-image "influxdb:2.0.0-
|
81
|
+
default: &default-influxdb-image "influxdb:2.0.0-rc"
|
82
82
|
docker:
|
83
83
|
- image: << parameters.ruby-image >>
|
84
84
|
- image: &influx-image quay.io/influxdb/<< parameters.influxdb-image >>
|
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,17 @@
|
|
1
|
-
## 1.
|
1
|
+
## 1.9.0 [unreleased]
|
2
|
+
|
3
|
+
## 1.8.0 [2020-10-02]
|
2
4
|
|
3
5
|
### Features
|
4
6
|
1. [#36](https://github.com/influxdata/influxdb-client-ruby/issues/36): Added support for default tags
|
7
|
+
1. [#53](https://github.com/influxdata/influxdb-client-ruby/pull/53): Default strategy for batching worker is best-effort
|
5
8
|
|
6
9
|
### API
|
7
10
|
1. [#50](https://github.com/influxdata/influxdb-client-ruby/pull/50): Default port changed from 9999 -> 8086
|
8
11
|
|
12
|
+
### Bug Fixes
|
13
|
+
1. [#52](https://github.com/influxdata/influxdb-client-ruby/pull/52): Fixed aborting of background threads
|
14
|
+
|
9
15
|
## 1.7.0 [2020-08-14]
|
10
16
|
|
11
17
|
### Features
|
data/README.md
CHANGED
@@ -23,7 +23,7 @@ The client can be installed manually or with bundler.
|
|
23
23
|
To install the client gem manually:
|
24
24
|
|
25
25
|
```
|
26
|
-
gem install influxdb-client -v 1.
|
26
|
+
gem install influxdb-client -v 1.8.0
|
27
27
|
```
|
28
28
|
|
29
29
|
## Usage
|
@@ -128,6 +128,7 @@ The writes are processed in batches which are configurable by `WriteOptions`:
|
|
128
128
|
| max_retries | the number of max retries when write fails | 5 |
|
129
129
|
| max_retry_delay | maximum delay when retrying write in milliseconds | 180000 |
|
130
130
|
| exponential_base | the base for the exponential retry delay, the next delay is computed as `retry_interval * exponential_base^(attempts - 1) + random(jitter_interval)` | 5 |
|
131
|
+
| batch_abort_on_exception | the batching worker will be aborted after failed retry strategy | false |
|
131
132
|
```ruby
|
132
133
|
write_options = InfluxDB2::WriteOptions.new(write_type: InfluxDB2::WriteType::BATCHING,
|
133
134
|
batch_size: 10, flush_interval: 5_000,
|
data/bin/influxdb-restart.sh
CHANGED
@@ -27,7 +27,7 @@ DEFAULT_DOCKER_REGISTRY="quay.io/influxdb/"
|
|
27
27
|
DOCKER_REGISTRY="${DOCKER_REGISTRY:-$DEFAULT_DOCKER_REGISTRY}"
|
28
28
|
|
29
29
|
DEFAULT_INFLUXDB_V2_REPOSITORY="influxdb"
|
30
|
-
DEFAULT_INFLUXDB_V2_VERSION="2.0.0-
|
30
|
+
DEFAULT_INFLUXDB_V2_VERSION="2.0.0-rc"
|
31
31
|
INFLUXDB_V2_REPOSITORY="${INFLUXDB_V2_REPOSITORY:-$DEFAULT_INFLUXDB_V2_REPOSITORY}"
|
32
32
|
INFLUXDB_V2_VERSION="${INFLUXDB_V2_VERSION:-$DEFAULT_INFLUXDB_V2_VERSION}"
|
33
33
|
INFLUXDB_V2_IMAGE=${DOCKER_REGISTRY}${INFLUXDB_V2_REPOSITORY}:${INFLUXDB_V2_VERSION}
|
@@ -31,14 +31,13 @@ module InfluxDB2
|
|
31
31
|
|
32
32
|
@queue_event.push(true)
|
33
33
|
|
34
|
-
Thread.abort_on_exception = true
|
35
|
-
|
36
34
|
@thread_flush = Thread.new do
|
37
35
|
until api_client.closed
|
38
36
|
sleep @write_options.flush_interval.to_f / 1_000
|
39
37
|
_check_background_queue
|
40
38
|
end
|
41
39
|
end
|
40
|
+
@thread_flush.abort_on_exception = @write_options.batch_abort_on_exception
|
42
41
|
|
43
42
|
@thread_size = Thread.new do
|
44
43
|
until api_client.closed
|
@@ -46,6 +45,7 @@ module InfluxDB2
|
|
46
45
|
sleep 0.01
|
47
46
|
end
|
48
47
|
end
|
48
|
+
@thread_size.abort_on_exception = @write_options.batch_abort_on_exception
|
49
49
|
end
|
50
50
|
|
51
51
|
def push(payload)
|
@@ -39,8 +39,10 @@ module InfluxDB2
|
|
39
39
|
# by a random amount
|
40
40
|
# @param [Integer] exponential_base: base for the exponential retry delay, the next delay is computed as
|
41
41
|
# "exponential_base^(attempts-1) + random(jitter_interval)"
|
42
|
+
# @param [Boolean] batch_abort_on_exception: batching worker will be aborted after failed retry strategy
|
42
43
|
def initialize(write_type: WriteType::SYNCHRONOUS, batch_size: 1_000, flush_interval: 1_000, retry_interval: 5_000,
|
43
|
-
jitter_interval: 0, max_retries: 5, max_retry_delay: 180_000, exponential_base: 5
|
44
|
+
jitter_interval: 0, max_retries: 5, max_retry_delay: 180_000, exponential_base: 5,
|
45
|
+
batch_abort_on_exception: false)
|
44
46
|
_check_not_negative('batch_size', batch_size)
|
45
47
|
_check_not_negative('flush_interval', flush_interval)
|
46
48
|
_check_not_negative('retry_interval', retry_interval)
|
@@ -56,10 +58,11 @@ module InfluxDB2
|
|
56
58
|
@max_retries = max_retries
|
57
59
|
@max_retry_delay = max_retry_delay
|
58
60
|
@exponential_base = exponential_base
|
61
|
+
@batch_abort_on_exception = batch_abort_on_exception
|
59
62
|
end
|
60
63
|
|
61
64
|
attr_reader :write_type, :batch_size, :flush_interval, :retry_interval, :jitter_interval,
|
62
|
-
:max_retries, :max_retry_delay, :exponential_base
|
65
|
+
:max_retries, :max_retry_delay, :exponential_base, :batch_abort_on_exception
|
63
66
|
|
64
67
|
def _check_not_negative(key, value)
|
65
68
|
raise ArgumentError, "The '#{key}' should be positive or zero, but is: #{value}" if value <= 0
|
@@ -73,12 +73,16 @@ class DeleteApiIntegrationTest < MiniTest::Test
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def test_delete_all
|
76
|
+
# TODO: https://github.com/influxdata/influxdb/issues/19545
|
77
|
+
skip
|
76
78
|
@client.create_delete_api.delete(Time.utc(2010, 10, 15, 7, 20, 15), Time.utc(2020, 10, 14, 8, 20, 15))
|
77
79
|
|
78
80
|
assert_equal 0, _query_count
|
79
81
|
end
|
80
82
|
|
81
83
|
def test_delete_without_interval
|
84
|
+
# TODO: https://github.com/influxdata/influxdb/issues/19545
|
85
|
+
skip
|
82
86
|
error = assert_raises InfluxDB2::InfluxError do
|
83
87
|
@client.create_delete_api.delete(nil, nil)
|
84
88
|
end
|
@@ -338,38 +338,34 @@ class WriteApiRetryStrategyTest < MiniTest::Test
|
|
338
338
|
batch_size: 1, retry_interval: 2_000, max_retries: 3,
|
339
339
|
max_retry_delay: 5_000, exponential_base: 2)
|
340
340
|
|
341
|
-
|
342
|
-
@client.create_write_api(write_options: write_options).write(data: point)
|
343
|
-
|
344
|
-
sleep(0.5)
|
341
|
+
@client.create_write_api(write_options: write_options).write(data: point)
|
345
342
|
|
346
|
-
|
347
|
-
times: 1, body: request)
|
343
|
+
sleep(0.5)
|
348
344
|
|
349
|
-
|
345
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
346
|
+
times: 1, body: request)
|
350
347
|
|
351
|
-
|
352
|
-
times: 2, body: request)
|
348
|
+
sleep(2)
|
353
349
|
|
354
|
-
|
350
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
351
|
+
times: 2, body: request)
|
355
352
|
|
356
|
-
|
357
|
-
times: 3, body: request)
|
353
|
+
sleep(4)
|
358
354
|
|
359
|
-
|
355
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
356
|
+
times: 3, body: request)
|
360
357
|
|
361
|
-
|
362
|
-
times: 4, body: request)
|
358
|
+
sleep(5)
|
363
359
|
|
364
|
-
|
360
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
361
|
+
times: 4, body: request)
|
365
362
|
|
366
|
-
|
367
|
-
times: 4, body: request)
|
363
|
+
sleep(5)
|
368
364
|
|
369
|
-
|
370
|
-
|
365
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
366
|
+
times: 4, body: request)
|
371
367
|
|
372
|
-
|
368
|
+
sleep(5)
|
373
369
|
|
374
370
|
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
375
371
|
times: 4, body: request)
|
@@ -384,7 +380,8 @@ class WriteApiRetryStrategyTest < MiniTest::Test
|
|
384
380
|
|
385
381
|
write_options = InfluxDB2::WriteOptions.new(write_type: InfluxDB2::WriteType::BATCHING,
|
386
382
|
batch_size: 1, retry_interval: 2_000, max_retries: 3,
|
387
|
-
max_retry_delay: 5_000, exponential_base: 2
|
383
|
+
max_retry_delay: 5_000, exponential_base: 2,
|
384
|
+
batch_abort_on_exception: true)
|
388
385
|
|
389
386
|
error = assert_raises InfluxDB2::InfluxError do
|
390
387
|
@client.create_write_api(write_options: write_options).write(data: 'h2o,location=west value=33i 15')
|
@@ -420,33 +417,29 @@ class WriteApiRetryStrategyTest < MiniTest::Test
|
|
420
417
|
batch_size: 1, retry_interval: 2_000, max_retries: 3,
|
421
418
|
max_retry_delay: 5_000, exponential_base: 2)
|
422
419
|
|
423
|
-
|
424
|
-
@client.create_write_api(write_options: write_options).write(data: point)
|
425
|
-
|
426
|
-
sleep(0.5)
|
420
|
+
@client.create_write_api(write_options: write_options).write(data: point)
|
427
421
|
|
428
|
-
|
429
|
-
times: 1, body: request)
|
422
|
+
sleep(0.5)
|
430
423
|
|
431
|
-
|
424
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
425
|
+
times: 1, body: request)
|
432
426
|
|
433
|
-
|
434
|
-
times: 2, body: request)
|
427
|
+
sleep(3)
|
435
428
|
|
436
|
-
|
429
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
430
|
+
times: 2, body: request)
|
437
431
|
|
438
|
-
|
439
|
-
times: 3, body: request)
|
432
|
+
sleep(3)
|
440
433
|
|
441
|
-
|
434
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
435
|
+
times: 3, body: request)
|
442
436
|
|
443
|
-
|
444
|
-
times: 4, body: request)
|
437
|
+
sleep(3)
|
445
438
|
|
446
|
-
|
447
|
-
|
439
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
440
|
+
times: 4, body: request)
|
448
441
|
|
449
|
-
|
442
|
+
sleep(3)
|
450
443
|
|
451
444
|
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
452
445
|
times: 4, body: request)
|
@@ -473,38 +466,37 @@ class WriteApiRetryStrategyTest < MiniTest::Test
|
|
473
466
|
batch_size: 1, retry_interval: 2_000, max_retries: 3,
|
474
467
|
max_retry_delay: 5_000, exponential_base: 2)
|
475
468
|
|
476
|
-
|
477
|
-
@client.create_write_api(write_options: write_options).write(data: point)
|
469
|
+
@client.create_write_api(write_options: write_options).write(data: point)
|
478
470
|
|
479
|
-
|
471
|
+
sleep(0.5)
|
480
472
|
|
481
|
-
|
482
|
-
|
473
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
474
|
+
times: 1, body: request)
|
483
475
|
|
484
|
-
|
476
|
+
sleep(2)
|
485
477
|
|
486
|
-
|
487
|
-
|
478
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
479
|
+
times: 2, body: request)
|
488
480
|
|
489
|
-
|
481
|
+
sleep(4)
|
490
482
|
|
491
|
-
|
492
|
-
|
483
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
484
|
+
times: 3, body: request)
|
493
485
|
|
494
|
-
|
486
|
+
sleep(5)
|
495
487
|
|
496
|
-
|
497
|
-
|
488
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
489
|
+
times: 4, body: request)
|
498
490
|
|
499
|
-
|
491
|
+
sleep(5)
|
500
492
|
|
501
|
-
|
502
|
-
|
493
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
494
|
+
times: 4, body: request)
|
503
495
|
|
504
|
-
|
505
|
-
end
|
496
|
+
sleep(5)
|
506
497
|
|
507
|
-
|
498
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
499
|
+
times: 4, body: request)
|
508
500
|
end
|
509
501
|
|
510
502
|
def test_write_connection_error
|
@@ -545,4 +537,61 @@ class WriteApiRetryStrategyTest < MiniTest::Test
|
|
545
537
|
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
546
538
|
times: 3, body: request)
|
547
539
|
end
|
540
|
+
|
541
|
+
def test_abort_on_exception
|
542
|
+
error_body = '{"code":"invalid","message":"unable to parse '\
|
543
|
+
'\'h2o,location=europe 1\'"}'
|
544
|
+
|
545
|
+
stub_request(:any, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
546
|
+
.to_return(status: 400, headers: { 'X-Platform-Error-Code' => 'invalid' }, body: error_body)
|
547
|
+
.to_return(status: 204)
|
548
|
+
|
549
|
+
write_options = InfluxDB2::WriteOptions.new(write_type: InfluxDB2::WriteType::BATCHING,
|
550
|
+
batch_size: 1, retry_interval: 500, max_retries: 1,
|
551
|
+
max_retry_delay: 5_000, exponential_base: 1,
|
552
|
+
batch_abort_on_exception: true)
|
553
|
+
|
554
|
+
write_api = @client.create_write_api(write_options: write_options)
|
555
|
+
|
556
|
+
error = assert_raises InfluxDB2::InfluxError do
|
557
|
+
write_api.write(data: 'h2o,location=europe 1')
|
558
|
+
write_api.write(data: 'h2o,location=europe level=2.0 1')
|
559
|
+
|
560
|
+
sleep(2)
|
561
|
+
end
|
562
|
+
|
563
|
+
assert_equal("unable to parse 'h2o,location=europe 1'", error.message)
|
564
|
+
|
565
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
566
|
+
times: 1, body: 'h2o,location=europe 1')
|
567
|
+
|
568
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
569
|
+
times: 0, body: 'h2o,location=europe level=2.0 1')
|
570
|
+
end
|
571
|
+
|
572
|
+
def test_abort_on_exception_next_batch
|
573
|
+
error_body = '{"code":"invalid","message":"unable to parse '\
|
574
|
+
'\'h2o,location=europe 1\'"}'
|
575
|
+
|
576
|
+
stub_request(:any, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
577
|
+
.to_return(status: 400, headers: { 'X-Platform-Error-Code' => 'invalid' }, body: error_body)
|
578
|
+
.to_return(status: 204)
|
579
|
+
|
580
|
+
write_options = InfluxDB2::WriteOptions.new(write_type: InfluxDB2::WriteType::BATCHING,
|
581
|
+
batch_size: 1, retry_interval: 500, max_retries: 1,
|
582
|
+
max_retry_delay: 5_000, exponential_base: 1)
|
583
|
+
|
584
|
+
write_api = @client.create_write_api(write_options: write_options)
|
585
|
+
|
586
|
+
write_api.write(data: 'h2o,location=europe 1')
|
587
|
+
write_api.write(data: 'h2o,location=europe level=2.0 1')
|
588
|
+
|
589
|
+
sleep(2)
|
590
|
+
|
591
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
592
|
+
times: 1, body: 'h2o,location=europe 1')
|
593
|
+
|
594
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
595
|
+
times: 1, body: 'h2o,location=europe level=2.0 1')
|
596
|
+
end
|
548
597
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: influxdb-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0.pre.1301
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakub Bednar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|