jay_api 29.5.0 → 29.7.0
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 +4 -4
- data/CHANGELOG.md +20 -0
- data/lib/jay_api/elasticsearch/client.rb +16 -26
- data/lib/jay_api/elasticsearch/cluster.rb +33 -0
- data/lib/jay_api/elasticsearch/mixins/retriable_requests.rb +79 -0
- data/lib/jay_api/elasticsearch/mixins.rb +10 -0
- data/lib/jay_api/elasticsearch/tasks.rb +42 -2
- data/lib/jay_api/elasticsearch.rb +2 -0
- data/lib/jay_api/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 469981ee390e1c409ff7e4e3faef1d9fb3579e87c9f1e2262f1664ba8d4731c3
|
|
4
|
+
data.tar.gz: 0f9b84be25dfc1a2f318edb8ae462714553e7898c278e1da0b9e38d211049719
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 23f0fd77caa519085f05b6efeff92c128895a912ffa3e75d83703f3b4a7b27cf76e39dfcb42652461fc730c3ff790df67913f0d7f52926ab8bebec86cf02196b
|
|
7
|
+
data.tar.gz: 48c2c4d5c97ef87fe7ce9ca0809d4b650549db40b654bb7b856438462b6b1c482bdd83f5c11840428fac5f51fc51cbc08cf43bec996f22abdf2e08a4f87050f8
|
data/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,26 @@ Please mark backwards incompatible changes with an exclamation mark at the start
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [29.7.0] - 2026-04-28
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
- The `#cluster` method to `JayAPI::Elasticsearch::Client`. The method returns
|
|
15
|
+
an instance of `JayAPI::Elasticsearch::Cluster`.
|
|
16
|
+
- The `Elasticsearch::Cluster` class. The class gives the user access to
|
|
17
|
+
cluster-level endpoints, currently including cluster health.
|
|
18
|
+
|
|
19
|
+
## [29.6.0] - 2026-03-16
|
|
20
|
+
|
|
21
|
+
### Deprecated
|
|
22
|
+
- The `#task_by_id` method of the `Elasticsearch::Client` class.
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
- The `#all` method to `JayAPI::Elasticsearch::Tasks`. The method returns the
|
|
26
|
+
status of all running tasks on the Elasticsearch cluster.
|
|
27
|
+
- The `#tasks` method to `JayAPI::Elasticsearch::Client`. The method returns an
|
|
28
|
+
instance of `JayAPI::Elasticsearch::Tasks`, which gives the user access to the
|
|
29
|
+
status of the tasks running on the Elasticsearch cluster.
|
|
30
|
+
|
|
11
31
|
## [29.5.0] - 2026-02-23
|
|
12
32
|
|
|
13
33
|
### Fixed
|
|
@@ -1,39 +1,24 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'timeout'
|
|
4
|
-
require 'elasticsearch/transport/transport/errors'
|
|
5
4
|
require 'faraday/error'
|
|
6
5
|
require 'forwardable'
|
|
7
6
|
|
|
8
|
-
require_relative '
|
|
7
|
+
require_relative 'mixins/retriable_requests'
|
|
8
|
+
require_relative 'cluster'
|
|
9
9
|
require_relative 'stats'
|
|
10
|
+
require_relative 'tasks'
|
|
10
11
|
|
|
11
12
|
module JayAPI
|
|
12
13
|
module Elasticsearch
|
|
13
|
-
# The JayAPI wrapper class over the
|
|
14
|
+
# The JayAPI wrapper class over the +Elasticsearch::Client+ object. It mirrors
|
|
14
15
|
# the object's API, but if one of the ERRORS is raised, this Wrapper class will
|
|
15
16
|
# rescue the error up to a few times and re-try the connection. This way the
|
|
16
17
|
# connection to Elasticsearch will be more robust.
|
|
17
18
|
class Client
|
|
18
19
|
extend Forwardable
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
ERRORS = [
|
|
22
|
-
::Elasticsearch::Transport::Transport::ServerError,
|
|
23
|
-
Faraday::TimeoutError
|
|
24
|
-
].freeze
|
|
25
|
-
|
|
26
|
-
# Subclasses of the +Elasticsearch::Transport::Transport::ServerError+
|
|
27
|
-
# for which a retry doesn't make sense.
|
|
28
|
-
NON_RETRIABLE_ERRORS = [
|
|
29
|
-
::Elasticsearch::Transport::Transport::Errors::BadRequest,
|
|
30
|
-
::Elasticsearch::Transport::Transport::Errors::Unauthorized,
|
|
31
|
-
::Elasticsearch::Transport::Transport::Errors::Forbidden,
|
|
32
|
-
::Elasticsearch::Transport::Transport::Errors::NotFound,
|
|
33
|
-
::Elasticsearch::Transport::Transport::Errors::MethodNotAllowed,
|
|
34
|
-
::Elasticsearch::Transport::Transport::Errors::RequestEntityTooLarge,
|
|
35
|
-
::Elasticsearch::Transport::Transport::Errors::NotImplemented
|
|
36
|
-
].freeze
|
|
21
|
+
include JayAPI::Elasticsearch::Mixins::RetriableRequests
|
|
37
22
|
|
|
38
23
|
attr_reader :transport_client, :logger, :max_attempts, :wait_strategy
|
|
39
24
|
|
|
@@ -88,6 +73,7 @@ module JayAPI
|
|
|
88
73
|
# parameters. If the request fails, additional retries will be performed.
|
|
89
74
|
# @see Elasticsearch::Client#tasks for more info about the arguments and
|
|
90
75
|
# the return value.
|
|
76
|
+
# @deprecated Use Tasks#by_id instead.
|
|
91
77
|
def task_by_id(**args)
|
|
92
78
|
retry_request { transport_client.tasks.get(**args) }
|
|
93
79
|
end
|
|
@@ -98,13 +84,17 @@ module JayAPI
|
|
|
98
84
|
@stats ||= ::JayAPI::Elasticsearch::Stats.new(transport_client)
|
|
99
85
|
end
|
|
100
86
|
|
|
101
|
-
|
|
87
|
+
# @return [JayAPI::Elasticsearch::Tasks] An instance of the +Tasks+ class,
|
|
88
|
+
# which can be used to retrieve the status of the tasks running on the
|
|
89
|
+
# Elasticsearch cluster.
|
|
90
|
+
def tasks
|
|
91
|
+
@tasks ||= ::JayAPI::Elasticsearch::Tasks.new(client: self)
|
|
92
|
+
end
|
|
102
93
|
|
|
103
|
-
# @
|
|
104
|
-
#
|
|
105
|
-
def
|
|
106
|
-
|
|
107
|
-
.retry(errors: ERRORS, except: NON_RETRIABLE_ERRORS, &block)
|
|
94
|
+
# @return [JayAPI::Elasticsearch::Cluster] An instance of the +Cluster+
|
|
95
|
+
# class, which gives the caller access to cluster-related endpoints.
|
|
96
|
+
def cluster
|
|
97
|
+
@cluster ||= ::JayAPI::Elasticsearch::Cluster.new(transport_client)
|
|
108
98
|
end
|
|
109
99
|
end
|
|
110
100
|
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'forwardable'
|
|
4
|
+
|
|
5
|
+
require_relative 'mixins/retriable_requests'
|
|
6
|
+
|
|
7
|
+
module JayAPI
|
|
8
|
+
module Elasticsearch
|
|
9
|
+
# Represents the Elasticsearch cluster and provides access to
|
|
10
|
+
# cluster-level APIs.
|
|
11
|
+
class Cluster
|
|
12
|
+
extend Forwardable
|
|
13
|
+
|
|
14
|
+
def_delegator :cluster_client, :health
|
|
15
|
+
|
|
16
|
+
attr_reader :transport_client
|
|
17
|
+
|
|
18
|
+
# @param [Elasticsearch::Transport::Client] transport_client The transport
|
|
19
|
+
# client to use to make requests to the cluster.
|
|
20
|
+
def initialize(transport_client)
|
|
21
|
+
@transport_client = transport_client
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
# @return [Elasticsearch::API::Cluster::ClusterClient] The client used to
|
|
27
|
+
# access cluster-related information.
|
|
28
|
+
def cluster_client
|
|
29
|
+
@cluster_client ||= transport_client.cluster
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'elasticsearch/transport/transport/errors'
|
|
4
|
+
|
|
5
|
+
require_relative '../../abstract/connection'
|
|
6
|
+
|
|
7
|
+
module JayAPI
|
|
8
|
+
module Elasticsearch
|
|
9
|
+
module Mixins
|
|
10
|
+
# A mixin that allows the including class to retry requests to
|
|
11
|
+
# Elasticsearch by leveraging the +Abstract::Connection+ class'
|
|
12
|
+
# capabilities.
|
|
13
|
+
module RetriableRequests
|
|
14
|
+
# The errors that, if raised, must cause a retry of the connection.
|
|
15
|
+
RETRIABLE_ERRORS = [
|
|
16
|
+
::Elasticsearch::Transport::Transport::ServerError,
|
|
17
|
+
Faraday::TimeoutError
|
|
18
|
+
].freeze
|
|
19
|
+
|
|
20
|
+
# Subclasses of the +Elasticsearch::Transport::Transport::ServerError+
|
|
21
|
+
# for which a retry doesn't make sense.
|
|
22
|
+
NON_RETRIABLE_ERRORS = [
|
|
23
|
+
::Elasticsearch::Transport::Transport::Errors::BadRequest,
|
|
24
|
+
::Elasticsearch::Transport::Transport::Errors::Unauthorized,
|
|
25
|
+
::Elasticsearch::Transport::Transport::Errors::Forbidden,
|
|
26
|
+
::Elasticsearch::Transport::Transport::Errors::NotFound,
|
|
27
|
+
::Elasticsearch::Transport::Transport::Errors::MethodNotAllowed,
|
|
28
|
+
::Elasticsearch::Transport::Transport::Errors::RequestEntityTooLarge,
|
|
29
|
+
::Elasticsearch::Transport::Transport::Errors::NotImplemented
|
|
30
|
+
].freeze
|
|
31
|
+
|
|
32
|
+
# @return [Integer] The maximum number of times a request should be
|
|
33
|
+
# retried before giving up.
|
|
34
|
+
def max_attempts
|
|
35
|
+
raise_not_implemented(__method__)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# @return [JayAPI::Elasticsearch::WaitStrategy] The waiting strategy for
|
|
39
|
+
# retries.
|
|
40
|
+
def wait_strategy
|
|
41
|
+
raise_not_implemented(__method__)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# @return [Logging::Logger] A logger to log messages.
|
|
45
|
+
def logger
|
|
46
|
+
raise_not_implemented(__method__)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# @return [Array<Class>] The array of errors that, if raised, must cause
|
|
50
|
+
# a retry of the request.
|
|
51
|
+
def retriable_errors
|
|
52
|
+
RETRIABLE_ERRORS
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# @return [Array<Class>] An array of subclasses of the
|
|
56
|
+
# +Elasticsearch::Transport::Transport::ServerError+ for which a retry
|
|
57
|
+
# doesn't make sense.
|
|
58
|
+
def non_retriable_errors
|
|
59
|
+
NON_RETRIABLE_ERRORS
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
private
|
|
63
|
+
|
|
64
|
+
# Uses the +Abstract::Connection+ class to retry the request enclosed in
|
|
65
|
+
# the given block.
|
|
66
|
+
def retry_request(&)
|
|
67
|
+
Abstract::Connection.new(max_attempts:, wait_strategy: wait_strategy.dup, logger:)
|
|
68
|
+
.retry(errors: retriable_errors, except: non_retriable_errors, &)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# @raise [NotImplementedError] Is always raised with the appropriate
|
|
72
|
+
# error message.
|
|
73
|
+
def raise_not_implemented(method)
|
|
74
|
+
raise NotImplementedError, "Please implement the method ##{method} in #{self.class}"
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -1,22 +1,52 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'active_support'
|
|
4
|
+
require 'active_support/core_ext/enumerable'
|
|
4
5
|
require 'active_support/core_ext/hash/indifferent_access'
|
|
6
|
+
require 'forwardable'
|
|
7
|
+
|
|
8
|
+
require_relative 'mixins/retriable_requests'
|
|
5
9
|
|
|
6
10
|
module JayAPI
|
|
7
11
|
module Elasticsearch
|
|
8
12
|
# Represents Elasticsearch tasks. Returns information about the tasks
|
|
9
13
|
# currently executing in the cluster.
|
|
10
|
-
# TODO: Add #all [JAY-593]
|
|
11
14
|
class Tasks
|
|
15
|
+
extend Forwardable
|
|
16
|
+
include ::JayAPI::Elasticsearch::Mixins::RetriableRequests
|
|
17
|
+
|
|
12
18
|
attr_reader :client
|
|
13
19
|
|
|
20
|
+
def_delegators :client, :transport_client, :max_attempts, :wait_strategy, :logger
|
|
21
|
+
|
|
14
22
|
# @param [JayAPI::Elasticsearch::Client] client The Elasticsearch Client
|
|
15
23
|
# object
|
|
16
24
|
def initialize(client:)
|
|
17
25
|
@client = client
|
|
18
26
|
end
|
|
19
27
|
|
|
28
|
+
# Gets the list of tasks running on the Elasticsearch cluster.
|
|
29
|
+
# For more information about this endpoint and the parameters please see:
|
|
30
|
+
# https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-tasks-list
|
|
31
|
+
# @param [Array<String>] actions A list of actions. Only tasks matching
|
|
32
|
+
# these actions will be returned, if no task matches the result will be
|
|
33
|
+
# empty.
|
|
34
|
+
# @param [Boolean] detailed Whether or not the result should include task
|
|
35
|
+
# details or not.
|
|
36
|
+
# @return [Hash] A hash with the list of tasks running on the
|
|
37
|
+
# Elasticsearch cluster.
|
|
38
|
+
def all(actions: nil, detailed: false)
|
|
39
|
+
# Needed because unlike many Elasticsearch methods Tasks#list doesn't
|
|
40
|
+
# call #listify over +actions+.
|
|
41
|
+
actions = actions&.then do |value|
|
|
42
|
+
value.is_a?(Array) ? value.join(',') : value
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
retry_request do
|
|
46
|
+
tasks_client.list({ actions:, detailed: }.compact_blank)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
20
50
|
# Retrieves info about the task with the passed +task_id+
|
|
21
51
|
# For more information on how to build the query please refer to the
|
|
22
52
|
# Elasticsearch DSL documentation:
|
|
@@ -29,7 +59,17 @@ module JayAPI
|
|
|
29
59
|
# @raise [Elasticsearch::Transport::Transport::ServerError] If the
|
|
30
60
|
# query fails.
|
|
31
61
|
def by_id(task_id)
|
|
32
|
-
|
|
62
|
+
retry_request do
|
|
63
|
+
tasks_client.get(task_id:, wait_for_completion: true).deep_symbolize_keys
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
private
|
|
68
|
+
|
|
69
|
+
# @return [Elasticsearch::API::Tasks::TasksClient] The client used to
|
|
70
|
+
# access tasks-related information.
|
|
71
|
+
def tasks_client
|
|
72
|
+
@tasks_client ||= transport_client.tasks
|
|
33
73
|
end
|
|
34
74
|
end
|
|
35
75
|
end
|
|
@@ -4,10 +4,12 @@ require_relative 'elasticsearch/async'
|
|
|
4
4
|
require_relative 'elasticsearch/batch_counter'
|
|
5
5
|
require_relative 'elasticsearch/client'
|
|
6
6
|
require_relative 'elasticsearch/client_factory'
|
|
7
|
+
require_relative 'elasticsearch/cluster'
|
|
7
8
|
require_relative 'elasticsearch/errors'
|
|
8
9
|
require_relative 'elasticsearch/index'
|
|
9
10
|
require_relative 'elasticsearch/indexes'
|
|
10
11
|
require_relative 'elasticsearch/indices'
|
|
12
|
+
require_relative 'elasticsearch/mixins'
|
|
11
13
|
require_relative 'elasticsearch/query_builder'
|
|
12
14
|
require_relative 'elasticsearch/query_results'
|
|
13
15
|
require_relative 'elasticsearch/response'
|
data/lib/jay_api/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jay_api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 29.
|
|
4
|
+
version: 29.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Accenture-Industry X
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2026-
|
|
12
|
+
date: 2026-04-28 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activesupport
|
|
@@ -121,6 +121,7 @@ files:
|
|
|
121
121
|
- lib/jay_api/elasticsearch/batch_counter.rb
|
|
122
122
|
- lib/jay_api/elasticsearch/client.rb
|
|
123
123
|
- lib/jay_api/elasticsearch/client_factory.rb
|
|
124
|
+
- lib/jay_api/elasticsearch/cluster.rb
|
|
124
125
|
- lib/jay_api/elasticsearch/errors.rb
|
|
125
126
|
- lib/jay_api/elasticsearch/errors/elasticsearch_error.rb
|
|
126
127
|
- lib/jay_api/elasticsearch/errors/end_of_query_results_error.rb
|
|
@@ -135,6 +136,8 @@ files:
|
|
|
135
136
|
- lib/jay_api/elasticsearch/indices.rb
|
|
136
137
|
- lib/jay_api/elasticsearch/indices/settings.rb
|
|
137
138
|
- lib/jay_api/elasticsearch/indices/settings/blocks.rb
|
|
139
|
+
- lib/jay_api/elasticsearch/mixins.rb
|
|
140
|
+
- lib/jay_api/elasticsearch/mixins/retriable_requests.rb
|
|
138
141
|
- lib/jay_api/elasticsearch/query_builder.rb
|
|
139
142
|
- lib/jay_api/elasticsearch/query_builder/aggregations.rb
|
|
140
143
|
- lib/jay_api/elasticsearch/query_builder/aggregations/aggregation.rb
|
|
@@ -225,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
225
228
|
- !ruby/object:Gem::Version
|
|
226
229
|
version: '0'
|
|
227
230
|
requirements: []
|
|
228
|
-
rubygems_version: 3.
|
|
231
|
+
rubygems_version: 3.4.19
|
|
229
232
|
signing_key:
|
|
230
233
|
specification_version: 4
|
|
231
234
|
summary: A collection of classes and modules to access JAY's functionality
|