influxdb-client 1.0.0.beta

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e203e9d1b0a4b60718bf0dfaaf61b51ecba01a8272d6d87b27961a2ee648e19e
4
+ data.tar.gz: 3ca6b8adf3d93095151f49c19707c01825935f7c2715af85e701550493f26c1d
5
+ SHA512:
6
+ metadata.gz: d35c17008c9cafaa987bc60373fa124ba11bde79e6b92b7f09de611e43e1031831a194d4a626791537d140926a2722a63588de9730592ab86cc7bfd4c7b49658
7
+ data.tar.gz: 33ce6e893e185b74d30210ab14494ee759f853678f12579ca982f065b6923091833e45032bf57ad654039416d5ba89c46cd0c6fea21fe3694aece586d75ce56c
@@ -0,0 +1,157 @@
1
+ #
2
+ # The MIT License
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to deal
6
+ # in the Software without restriction, including without limitation the rights
7
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in
12
+ # all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ # THE SOFTWARE.
21
+ #
22
+
23
+ version: 2.1
24
+
25
+ commands:
26
+ influxdb-onboarding:
27
+ steps:
28
+ - run:
29
+ name: "Post onBoarding request to InfluxDB 2"
30
+ command: ./bin/influxdb-onboarding.sh
31
+ prepare:
32
+ description: "Prepare environment to tests"
33
+ steps:
34
+ - checkout
35
+ - influxdb-onboarding
36
+ test:
37
+ parameters:
38
+ ruby-image:
39
+ type: string
40
+ steps:
41
+ - restore_cache:
42
+ name: Restoring Gem Cache
43
+ keys:
44
+ - &cache-key gem-cache-{{ checksum "influxdb-client.gemspec" }}-<< parameters.ruby-image >>
45
+ - gem-cache-{{ checksum "influxdb-client.gemspec" }}
46
+ - gem-cache-
47
+ - run:
48
+ name: Install dependencies
49
+ command: |
50
+ gem install bundler
51
+ bundle config set path 'vendor/bundle'
52
+ bundle install --jobs=4 --retry=3
53
+ - run:
54
+ name: Static code analyze
55
+ command: |
56
+ bundle exec rake rubocop
57
+ - run:
58
+ name: Run tests
59
+ command: |
60
+ export MINITEST_REPORTER=JUnitReporter
61
+ bundle exec rake test
62
+ - save_cache:
63
+ name: Saving Gem Cache
64
+ key: *cache-key
65
+ paths:
66
+ - ./vendor/bundle
67
+ when: always
68
+ storing-test-results:
69
+ steps:
70
+ - store_test_results:
71
+ path: test/reports
72
+
73
+ jobs:
74
+ tests-ruby:
75
+ parameters:
76
+ ruby-image:
77
+ type: string
78
+ default: &default-ruby-image "circleci/ruby:2.6-stretch"
79
+ influxdb-image:
80
+ type: string
81
+ default: &default-influxdb-image "influxdb:2.0.0-beta"
82
+ docker:
83
+ - image: << parameters.ruby-image >>
84
+ - image: &influx-image quay.io/influxdb/<< parameters.influxdb-image >>
85
+ steps:
86
+ - prepare
87
+ - test:
88
+ ruby-image: << parameters.ruby-image >>
89
+ - storing-test-results
90
+
91
+ deploy-preview:
92
+ parameters:
93
+ influxdb-image:
94
+ type: string
95
+ default: *default-influxdb-image
96
+ docker:
97
+ - image: *default-ruby-image
98
+ - image: *influx-image
99
+ steps:
100
+ - run:
101
+ name: Early return if this build is from a forked repository
102
+ command: |
103
+ if [[ $CIRCLE_PROJECT_USERNAME != "influxdata" ]]; then
104
+ echo "Nothing to do for forked repositories, so marking this step successful"
105
+ circleci step halt
106
+ fi
107
+ - checkout
108
+ - run:
109
+ name: Setup Rubygems
110
+ command: bash .circleci/setup-rubygems.sh
111
+ - run:
112
+ name: Build a Gem bundle
113
+ command: |
114
+ gem build influxdb-client.gemspec
115
+ - run:
116
+ name: Deploy pre-release into https://rubygems.org
117
+ command: |
118
+ gem push influxdb-client-*.pre.$CIRCLE_BUILD_NUM.gem
119
+ workflows:
120
+ version: 2
121
+ build:
122
+ jobs:
123
+ - tests-ruby:
124
+ name: ruby-2.7
125
+ ruby-image: "circleci/ruby:2.7-buster"
126
+ - tests-ruby:
127
+ name: ruby-2.6
128
+ - tests-ruby:
129
+ name: ruby-2.6-nightly
130
+ influxdb-image: "influx:nightly"
131
+ - tests-ruby:
132
+ name: ruby-2.5
133
+ ruby-image: "circleci/ruby:2.5-stretch"
134
+ - tests-ruby:
135
+ name: ruby-2.4
136
+ ruby-image: "circleci/ruby:2.4-stretch"
137
+ - deploy-preview:
138
+ requires:
139
+ - ruby-2.7
140
+ - ruby-2.6
141
+ - ruby-2.6-nightly
142
+ - ruby-2.5
143
+ - ruby-2.4
144
+ filters:
145
+ branches:
146
+ only: master
147
+
148
+ nightly:
149
+ triggers:
150
+ - schedule:
151
+ cron: "0 0 * * *"
152
+ filters:
153
+ branches:
154
+ only:
155
+ - master
156
+ jobs:
157
+ - tests-ruby
@@ -0,0 +1,3 @@
1
+ mkdir ~/.gem || true
2
+ echo -e "---\r\n:rubygems_api_key: $GEM_HOST_API_KEY" > ~/.gem/credentials
3
+ chmod 0600 ~/.gem/credentials
@@ -0,0 +1,8 @@
1
+ Closes #
2
+
3
+ _Briefly describe your proposed changes:_
4
+
5
+ - [ ] CHANGELOG.md updated
6
+ - [ ] Rebased/mergeable
7
+ - [ ] Tests pass
8
+ - [ ] Sign [CLA](https://influxdata.com/community/cla/) (if not already signed)
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.idea/
3
+ /.yardoc
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /Gemfile.lock
11
+ /test/reports/
12
+ .rakeTasks
13
+ /influxdb-client-*.gem
14
+ /TAGS
data/.rubocop.yml ADDED
@@ -0,0 +1,34 @@
1
+ #
2
+ # The MIT License
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to deal
6
+ # in the Software without restriction, including without limitation the rights
7
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in
12
+ # all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ # THE SOFTWARE.
21
+ #
22
+
23
+ Metrics/LineLength:
24
+ Max: 120
25
+ Metrics/MethodLength:
26
+ Max: 30
27
+ Metrics/ClassLength:
28
+ Max: 200
29
+ Metrics/AbcSize:
30
+ Max: 30
31
+ Metrics/CyclomaticComplexity:
32
+ Max: 15
33
+ Metrics/PerceivedComplexity:
34
+ Max: 15
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## 1.0.0.beta [2020-01-17]
2
+
3
+ ### Features
4
+ 1. [#4](https://github.com/influxdata/influxdb-client-ruby/pull/4): Added WriteApi that will be used for Fluentd plugin
5
+
data/Gemfile ADDED
@@ -0,0 +1,24 @@
1
+ # The MIT License
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ source 'https://rubygems.org'
22
+
23
+ # Specify your gem's dependencies in influxdb-client.gemspec
24
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Influxdata, Inc.
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,157 @@
1
+ # influxdb-client-ruby
2
+
3
+ [![CircleCI](https://circleci.com/gh/influxdata/influxdb-client-ruby.svg?style=svg)](https://circleci.com/gh/influxdata/influxdb-client-ruby)
4
+ [![codecov](https://codecov.io/gh/influxdata/influxdb-client-ruby/branch/master/graph/badge.svg)](https://codecov.io/gh/influxdata/influxdb-client-ruby)
5
+ [![Gem Version](https://badge.fury.io/rb/influxdb-client.svg)](https://badge.fury.io/rb/influxdb-client)
6
+ [![License](https://img.shields.io/github/license/influxdata/influxdb-client-ruby.svg)](https://github.com/influxdata/influxdb-client-ruby/blob/master/LICENSE)
7
+ [![GitHub issues](https://img.shields.io/github/issues-raw/influxdata/influxdb-client-ruby.svg)](https://github.com/influxdata/influxdb-client-ruby/issues)
8
+ [![GitHub pull requests](https://img.shields.io/github/issues-pr-raw/influxdata/influxdb-client-ruby.svg)](https://github.com/influxdata/influxdb-client-ruby/pulls)
9
+ [![Slack Status](https://img.shields.io/badge/slack-join_chat-white.svg?logo=slack&style=social)](https://www.influxdata.com/slack)
10
+
11
+ This repository contains the reference Ruby client for the InfluxDB 2.0.
12
+
13
+ #### Note: This library is for use with InfluxDB 2.x. For connecting to InfluxDB 1.x instances, please use the [influxdb-ruby](https://github.com/influxdata/influxdb-ruby) client.
14
+ #### Disclaimer: This library is a work in progress and should not be considered production ready yet.
15
+
16
+ ## Installation
17
+
18
+ The InfluxDB 2 client is bundled as a gem and is hosted on [Rubygems](https://rubygems.org/gems/influxdb-client).
19
+
20
+ ### Install the Gem
21
+
22
+ The client can be installed manually or with bundler.
23
+
24
+ To install the client gem manually:
25
+
26
+ ```
27
+ gem install influxdb-client -v 1.0.0.beta
28
+ ```
29
+
30
+ ## Usage
31
+
32
+ ### Creating a client
33
+
34
+ Use **InfluxDB::Client** to create a client connected to a running InfluxDB 2 instance.
35
+
36
+ ```ruby
37
+ client = InfluxDB2::Client.new('https://localhost:9999', 'my-token')
38
+ ```
39
+
40
+ #### Client Options
41
+
42
+ | Option | Description | Type | Default |
43
+ |---|---|---|---|
44
+ | bucket | Default destination bucket for writes | String | none |
45
+ | org | Default organization bucket for writes | String | none |
46
+ | precision | Default precision for the unix timestamps within the body line-protocol | String | none |
47
+ | open_timeout | Number of seconds to wait for the connection to open | Integer | 10 |
48
+ | write_timeout | Number of seconds to wait for one block of data to be written | Integer | 10 |
49
+ | read_timeout | Number of seconds to wait for one block of data to be read | Integer | 10 |
50
+ | max_redirect_count | Maximal number of followed HTTP redirects | Integer | 10 |
51
+ | use_ssl | Turn on/off SSL for HTTP communication | bool | true |
52
+
53
+ ```ruby
54
+ client = InfluxDB2::Client.new('https://localhost:9999', 'my-token',
55
+ bucket: 'my-bucket',
56
+ org: 'my-org',
57
+ precision: InfluxDB2::WritePrecision::NANOSECOND)
58
+ ```
59
+
60
+ ### Writing data
61
+
62
+ ```ruby
63
+ client = InfluxDB2::Client.new('https://localhost:9999', 'my-token',
64
+ bucket: 'my-bucket',
65
+ org: 'my-org',
66
+ precision: InfluxDB2::WritePrecision::NANOSECOND)
67
+
68
+ write_api = client.create_write_api
69
+ write_api.write(data: 'h2o,location=west value=33i 15')
70
+ ```
71
+
72
+ #### Time precision
73
+
74
+ Configure default time precision:
75
+ ```ruby
76
+ client = InfluxDB2::Client.new('https://localhost:9999', 'my-token',
77
+ bucket: 'my-bucket',
78
+ org: 'my-org',
79
+ precision: InfluxDB2::WritePrecision::NANOSECOND)
80
+ ```
81
+
82
+ Configure precision per write:
83
+ ```ruby
84
+ client = InfluxDB2::Client.new('https://localhost:9999', 'my-token',
85
+ bucket: 'my-bucket',
86
+ org: 'my-org')
87
+
88
+ write_api = client.create_write_api
89
+ write_api.write(data: 'h2o,location=west value=33i 15', precision: InfluxDB2::WritePrecision::SECOND)
90
+ ```
91
+
92
+ Allowed values for precision are:
93
+ - `InfluxDB::WritePrecision::NANOSECOND` for nanosecond
94
+ - `InfluxDB::WritePrecision::MICROSECOND` for microsecond
95
+ - `InfluxDB::WritePrecision::MILLISECOND` for millisecond
96
+ - `InfluxDB::WritePrecision::SECOND` for second
97
+
98
+ #### Configure destination
99
+
100
+ Default `bucket` and `organization` destination are configured via `InfluxDB::Client`:
101
+ ```ruby
102
+ client = InfluxDB2::Client.new('https://localhost:9999', 'my-token',
103
+ bucket: 'my-bucket',
104
+ org: 'my-org')
105
+ ```
106
+
107
+ but there is also possibility to override configuration per write:
108
+
109
+ ```ruby
110
+ client = InfluxDB2::Client.new('https://localhost:9999', 'my-token')
111
+
112
+ write_api = client.create_write_api
113
+ write_api.write(data: 'h2o,location=west value=33i 15', bucket: 'production-data', org: 'customer-1')
114
+ ```
115
+
116
+ #### Data format
117
+
118
+ The data could be written as:
119
+
120
+ 1. `String` that is formatted as a InfluxDB's line protocol
121
+ 1. `Hash` with keys: name, tags, fields and time
122
+ 1. [Data Point](https://github.com/influxdata/influxdb-client-ruby/blob/master/lib/influxdb/client/point.rb#L28) structure
123
+ 1. `Array` of above items
124
+
125
+ ```ruby
126
+ client = InfluxDB2::Client.new('https://localhost:9999', 'my-token',
127
+ bucket: 'my-bucket',
128
+ org: 'my-org',
129
+ precision: InfluxDB2::WritePrecision::NANOSECOND)
130
+
131
+ point = InfluxDB2::Point.new(name: 'h2o')
132
+ .add_tag('location', 'europe')
133
+ .add_field('level', 2)
134
+
135
+ hash = { name: 'h2o',
136
+ tags: { host: 'aws', region: 'us' },
137
+ fields: { level: 5, saturation: '99%' }, time: 123 }
138
+
139
+ write_api = client.create_write_api
140
+ write_api.write(data: ['h2o,location=west value=33i 15', point, hash])
141
+ ```
142
+
143
+ ## Local tests
144
+
145
+ ```
146
+ brew install wget # on a mac, if not yet installed!
147
+ bin/influxdb-restart.sh
148
+ rake test
149
+ ```
150
+
151
+ ## Contributing
152
+
153
+ Bug reports and pull requests are welcome on GitHub at https://github.com/influxdata/influxdb-client-ruby.
154
+
155
+ ## License
156
+
157
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).