antbird 0.3.0 → 0.5.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: 8d6972953a2ec1f37d057b6a9dd477593fc06a11b7f343f8c57d0f0fa9e31ee1
4
- data.tar.gz: bd672bd59f69c2c6d77f90714da1112f441a8d6372d1ce3a9ae641778e2ee2f6
3
+ metadata.gz: c8c2ff0b9a3dd9122be37ee481a7ddb606466b9d39eafd293a52d6586cde63af
4
+ data.tar.gz: dbb2577b6a4a89735da0e5612d222ab579b98542472459ded0ee01a5e5270732
5
5
  SHA512:
6
- metadata.gz: b2fea4c7232a0b7209a4c4729ee4ffcd7c4a985de2bf9ec718919b8c01577528fba618ea68a4811aebea5ec47c964baf6b8e0c668327afcf15679d84ee3a3bbc
7
- data.tar.gz: 04c28e273287890b585b500ce7733399057602a8ff52f8924445317d25d680134b944fbcfdc2950a0648bf8425e2e89fb06ae3255dc25683a670ad4babe560a1
6
+ metadata.gz: 55b3cff8582335c0cb6dd6b1fb60004398858c805845ad88ee9fe64280a5fa26c7dc31ee7b6fdcc798c016b9365a096071c76a2e141ea911f6cae7eff5b86a0b
7
+ data.tar.gz: 1a2ab8f3115fd612c727466eb5438b6897a323b77f5dcdad70647a31758ac9f959f05446e8312fd3f8a9b7a46f00001656d265c74f82aa77eb02dc1becd5a845
@@ -0,0 +1,41 @@
1
+ name: build-os
2
+
3
+ on: [push]
4
+ env:
5
+ ENGINE_NAME: opensearch
6
+ REST_API_SPEC_REPO: opensearch-project/OpenSearch
7
+
8
+ jobs:
9
+ build:
10
+ runs-on: ubuntu-latest
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ # https://github.com/opensearch-project/OpenSearch/releases
15
+ search_versions:
16
+ - 1.2.0
17
+ - 1.1.0
18
+ - 1.0.0
19
+ services:
20
+ opensearch:
21
+ image: opensearchproject/opensearch:${{matrix.search_versions}}
22
+ ports:
23
+ - 9200:9200
24
+ env:
25
+ discovery.type: single-node
26
+ plugins.security.disabled: true
27
+ steps:
28
+ - name: Configure sysctl limits
29
+ run: |
30
+ sudo swapoff -a
31
+ sudo sysctl -w vm.swappiness=1
32
+ sudo sysctl -w fs.file-max=262144
33
+ sudo sysctl -w vm.max_map_count=262144
34
+ - uses: actions/checkout@v2
35
+ - uses: ruby/setup-ruby@v1
36
+ with:
37
+ ruby-version: 2.7
38
+ bundler-cache: true
39
+ - name: Wait for OpenSearch
40
+ run: timeout 60 bash -c "until curl --silent --output /dev/null localhost:9200/_cat/health?h=st; do printf '.'; sleep 5; done; printf '\n'"
41
+ - run: bundle exec rspec
@@ -1,6 +1,9 @@
1
1
  name: build
2
2
 
3
3
  on: [push]
4
+ env:
5
+ ENGINE_NAME: elasticsearch
6
+ REST_API_SPEC_REPO: elastic/elasticsearch
4
7
 
5
8
  jobs:
6
9
  build:
@@ -10,33 +13,33 @@ jobs:
10
13
  matrix:
11
14
  # 1. Run script/list_versions
12
15
  # 2. Check https://www.elastic.co/jp/support/eol
13
- elasticsearch:
14
- - 7.10.1
16
+ search_versions:
17
+ - 7.15.2
18
+ - 7.14.2
19
+ - 7.13.4
20
+ - 7.12.1
21
+ - 7.11.2
22
+ - 7.10.2
15
23
  - 7.9.3
16
24
  - 7.8.1
17
- - 7.7.1
18
- - 7.6.2
19
- - 7.5.2
20
- - 7.4.2
21
- - 7.3.2
22
- - 7.2.1
23
- - 7.1.1
24
- - 6.8.13
25
- services:
26
- elasticsearch:
27
- image: docker.elastic.co/elasticsearch/elasticsearch-oss:${{matrix.elasticsearch}}
28
- ports:
29
- - 9200:9200
30
- - 9300:9300
31
- env:
32
- discovery.type: single-node
25
+ - 6.8.18
33
26
  steps:
27
+ # @see https://github.com/elastic/elastic-github-actions/tree/master/elasticsearch
28
+ - name: Configure sysctl limits for Elasticsearch
29
+ run: |
30
+ sudo swapoff -a
31
+ sudo sysctl -w vm.swappiness=1
32
+ sudo sysctl -w fs.file-max=262144
33
+ sudo sysctl -w vm.max_map_count=262144
34
+ - name: Runs Elasticsearch
35
+ uses: elastic/elastic-github-actions/elasticsearch@master
36
+ with:
37
+ stack-version: ${{matrix.search_versions}}
34
38
  - uses: actions/checkout@v2
35
39
  - uses: ruby/setup-ruby@v1
36
40
  with:
37
41
  ruby-version: 2.7
38
42
  bundler-cache: true
39
- - run: bundle install --jobs 4 --retry 3
40
43
  - name: Wait for elasticsearch
41
44
  run: timeout 60 bash -c "until curl --silent --output /dev/null localhost:9200/_cat/health?h=st; do printf '.'; sleep 5; done; printf '\n'"
42
45
  - run: bundle exec rspec
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Antbird
2
2
 
3
- Nearly auto-generated Elasticsearch client
3
+ Nearly auto-generated Elasticsearch/OpenSearch client
4
4
 
5
5
  [![Build Status](https://github.com/fukayatsu/antbird/workflows/build/badge.svg)](https://github.com/fukayatsu/antbird/actions)
6
6
 
@@ -113,9 +113,9 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
113
113
 
114
114
  Bug reports and pull requests are welcome on GitHub at https://github.com/fukayatsu/antbird. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
115
115
 
116
- ### How to support newer version of Elasticsearch
116
+ ### How to support newer version of Elasticsearch/OpenSearch
117
117
 
118
- 1. Add Elasticsearch version to `jobs.build.strategy.matrix.elasticsearch` on `.github/workflows/build.yml`
118
+ 1. Add Elasticsearch version to `jobs.build.strategy.matrix.search_versions` on `.github/workflows/build.yml` / `.github/workflows/build-os.yml`
119
119
  - Only one line for `x.y.*` version
120
120
  1. `script/generate_api_methods`
121
121
  - Set `GITHUB_TOKEN=***` env for GitHub API Limit
@@ -8,6 +8,7 @@ module Antbird
8
8
  scope: {},
9
9
  url: "http://localhost:9200",
10
10
  version: nil,
11
+ distribution: nil,
11
12
  read_timeout: 5,
12
13
  open_timeout: 2,
13
14
  adapter: ::Faraday.default_adapter,
@@ -19,12 +20,16 @@ module Antbird
19
20
  @block = block
20
21
  @url = url
21
22
 
22
- @scope = scope.transform_keys(&:to_sym)
23
- @version = version
23
+ @scope = scope.transform_keys(&:to_sym)
24
+
25
+ if version
26
+ @version = version
27
+ @distribution = distribution
28
+ end
24
29
 
25
30
  @api_specs = {}
26
31
  end
27
- attr_reader :scope, :url, :version
32
+ attr_reader :scope, :url, :version, :distribution
28
33
  attr_reader :read_timeout, :open_timeout, :adapter
29
34
  attr_reader :api_specs, :last_request
30
35
 
@@ -33,6 +38,7 @@ module Antbird
33
38
  scope: new_scope,
34
39
  url: url,
35
40
  version: version,
41
+ distribution: distribution,
36
42
  read_timeout: read_timeout,
37
43
  open_timeout: open_timeout
38
44
  )
@@ -190,6 +196,28 @@ module Antbird
190
196
  end
191
197
  end
192
198
 
199
+ def elasticsearch?
200
+ !opensearch?
201
+ end
202
+
203
+ def opensearch?
204
+ ensure_version_and_distribution
205
+
206
+ distribution == 'opensearch'
207
+ end
208
+
209
+ def elasticsearch_v7_0_compatible?
210
+ return true if opensearch?
211
+
212
+ elasticsearch? && Gem::Version.new(version) >= Gem::Version.new('7.0.0')
213
+ end
214
+
215
+ def elasticsearch_v7_6_compatible?
216
+ return true if opensearch?
217
+
218
+ elasticsearch? && Gem::Version.new(version) >= Gem::Version.new('7.6.0')
219
+ end
220
+
193
221
  private
194
222
 
195
223
  # NOTE: stable sort
@@ -221,17 +249,30 @@ module Antbird
221
249
  end
222
250
  end
223
251
 
224
- def fetch_version
225
- connection.get('/').body.dig('version', 'number')
252
+ def ensure_version_and_distribution
253
+ return if version
254
+
255
+ version_hash = connection.get('/').body.dig('version')
256
+ @version = version_hash['number']
257
+ @distribution = version_hash['distribution']
258
+ end
259
+
260
+ def class_version
261
+ version.split('.')[0, 2].join('_')
226
262
  end
227
263
 
228
264
  def ensure_api_spec_loaded
229
265
  return if api_specs_loaded?
230
266
 
231
- @version ||= fetch_version
232
- class_version = @version.split('.')[0, 2].join('_')
233
- require "antbird/rest_api/rest_api_v#{class_version}"
234
- extend Antbird::RestApi.const_get "RestApiV#{class_version}"
267
+ ensure_version_and_distribution
268
+
269
+ if opensearch?
270
+ require "antbird/rest_api/rest_api_opensearch_v#{class_version}"
271
+ extend Antbird::RestApi.const_get "RestApiOpensearchV#{class_version}"
272
+ else
273
+ require "antbird/rest_api/rest_api_v#{class_version}"
274
+ extend Antbird::RestApi.const_get "RestApiV#{class_version}"
275
+ end
235
276
 
236
277
  @api_specs_loaded = true
237
278
  end