antbird 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: af75afbbb6d09da0a80a3ef3c15c12eca61410975581dd6f26997fa3f70272d0
4
- data.tar.gz: 5327fae6beaaecb226dea3ab8b04b3a88de6b47d3be77d23651f5c3840d4f26f
3
+ metadata.gz: 3c8c8fecccb123dbea652666e8c3afe9c0bb82b05addd4c16184285fc8d883fa
4
+ data.tar.gz: 300f03046a12082dc0f7ee92dc0283f1228cdc6dc1975cfa965e56d7baf065db
5
5
  SHA512:
6
- metadata.gz: ac456d024f7ad570b8dc3243a65895c74706ae9453bcdea5e0a8a52c98dcd38e2b3ca0c9f34290ed9483613d8facf50971c3dbde5d816bc011c37c9854141e1a
7
- data.tar.gz: 3266fefa55330b1a4180d16dfd54ac40b0bc91208b2253933d3648ed7bb7a02eab4eef49c41d173675a1c36932ca5b5391e3cb086df6df7b26f0a9ec1ad04467
6
+ metadata.gz: e5e54fed3437d547f92bfead50aeab29612694a955d6ed3f762962eaa29a7bec0743027557c8f0d15c82f032f5f5f188e138eb1a58a53afdb893b4e9abfa09b6
7
+ data.tar.gz: 37595c88f4e1df53b79d3f859c9a551d9ebfd49fd005f6e75136c91b677c84def615f3022bbac99149da8f00ff1991884c9a18a9d43f50e476fbfe2875adec6a
@@ -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,15 +13,15 @@ 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.14.0
16
+ search_versions:
17
+ - 7.15.2
18
+ - 7.14.2
15
19
  - 7.13.4
16
20
  - 7.12.1
17
21
  - 7.11.2
18
22
  - 7.10.2
19
23
  - 7.9.3
20
24
  - 7.8.1
21
- - 7.7.1
22
25
  - 6.8.18
23
26
  steps:
24
27
  # @see https://github.com/elastic/elastic-github-actions/tree/master/elasticsearch
@@ -31,13 +34,12 @@ jobs:
31
34
  - name: Runs Elasticsearch
32
35
  uses: elastic/elastic-github-actions/elasticsearch@master
33
36
  with:
34
- stack-version: ${{matrix.elasticsearch}}
37
+ stack-version: ${{matrix.search_versions}}
35
38
  - uses: actions/checkout@v2
36
39
  - uses: ruby/setup-ruby@v1
37
40
  with:
38
41
  ruby-version: 2.7
39
42
  bundler-cache: true
40
- - run: bundle install --jobs 4 --retry 3
41
43
  - name: Wait for elasticsearch
42
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'"
43
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,13 @@ 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
+ @version = version
25
+ @distribution = distribution
24
26
 
25
27
  @api_specs = {}
26
28
  end
27
- attr_reader :scope, :url, :version
29
+ attr_reader :scope, :url, :version, :distribution
28
30
  attr_reader :read_timeout, :open_timeout, :adapter
29
31
  attr_reader :api_specs, :last_request
30
32
 
@@ -33,6 +35,7 @@ module Antbird
33
35
  scope: new_scope,
34
36
  url: url,
35
37
  version: version,
38
+ distribution: distribution,
36
39
  read_timeout: read_timeout,
37
40
  open_timeout: open_timeout
38
41
  )
@@ -190,6 +193,27 @@ module Antbird
190
193
  end
191
194
  end
192
195
 
196
+ def elasticsearch?
197
+ !opensearch?
198
+ end
199
+
200
+ def opensearch?
201
+ fetch_version
202
+ distribution == 'opensearch'
203
+ end
204
+
205
+ def elasticsearch_v7_0_compatible?
206
+ return true if opensearch?
207
+
208
+ elasticsearch? && Gem::Version.new(version) >= Gem::Version.new('7.0.0')
209
+ end
210
+
211
+ def elasticsearch_v7_6_compatible?
212
+ return true if opensearch?
213
+
214
+ elasticsearch? && Gem::Version.new(version) >= Gem::Version.new('7.6.0')
215
+ end
216
+
193
217
  private
194
218
 
195
219
  # NOTE: stable sort
@@ -222,16 +246,25 @@ module Antbird
222
246
  end
223
247
 
224
248
  def fetch_version
225
- connection.get('/').body.dig('version', 'number')
249
+ return if @version
250
+
251
+ version_hash = connection.get('/').body.dig('version')
252
+ @version ||= version_hash['number']
253
+ @distribution ||= version_hash['distribution']
226
254
  end
227
255
 
228
256
  def ensure_api_spec_loaded
229
257
  return if api_specs_loaded?
230
258
 
231
- @version ||= fetch_version
259
+ fetch_version
232
260
  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}"
261
+ if opensearch?
262
+ require "antbird/rest_api/rest_api_opensearch_v#{class_version}"
263
+ extend Antbird::RestApi.const_get "RestApiOpensearchV#{class_version}"
264
+ else
265
+ require "antbird/rest_api/rest_api_v#{class_version}"
266
+ extend Antbird::RestApi.const_get "RestApiV#{class_version}"
267
+ end
235
268
 
236
269
  @api_specs_loaded = true
237
270
  end