jay_api 28.1.0 → 28.2.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 +6 -0
- data/lib/jay_api/elasticsearch/stats/errors/stats_data_not_available.rb +15 -0
- data/lib/jay_api/elasticsearch/stats/node/storage.rb +55 -0
- data/lib/jay_api/elasticsearch/stats/node.rb +45 -0
- data/lib/jay_api/elasticsearch/stats/nodes.rb +46 -0
- data/lib/jay_api/elasticsearch/stats.rb +24 -4
- data/lib/jay_api/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60468cdd7dbfd248e2ca373126f6d3f3a0e9c0d23d169a7e9d98aebe9de3d91d
|
4
|
+
data.tar.gz: 58ad9adc3a1f77139660338f213a9c835d935fc7a968f5971fe900904c1ba649
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a4c5a8ee131631eb7220b2c2cbf5eb4d9a081b3a0d817647c09d4027311629b78262b35707d8288418da5395d5bebdea11855d9a7f81b81f3d2566cc6156852
|
7
|
+
data.tar.gz: f596eeb92e9cecc97ffd2dccb9e93a2dfcf82524bd9bbed43b86ff2d3e60b011e6d9239923b2a4030ea1f0ab67c644028c3178c483de40455c2058c311e38e88
|
data/CHANGELOG.md
CHANGED
@@ -8,6 +8,12 @@ Please mark backwards incompatible changes with an exclamation mark at the start
|
|
8
8
|
|
9
9
|
## [Unreleased]
|
10
10
|
|
11
|
+
## [28.2.0] - 2025-05-30
|
12
|
+
|
13
|
+
### Added
|
14
|
+
- The `#nodes` method to the `Elasticsearch::Stats` class. This method gives the
|
15
|
+
user access to the node-related statistics of the Elasticsearch cluster.
|
16
|
+
|
11
17
|
## [28.1.0] - 2025-05-19
|
12
18
|
|
13
19
|
### Added
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../errors/error'
|
4
|
+
|
5
|
+
module JayAPI
|
6
|
+
module Elasticsearch
|
7
|
+
class Stats
|
8
|
+
module Errors
|
9
|
+
# An error to be raised when a particular Stats element is requested for
|
10
|
+
# which there is no data in the response received from the cluster.
|
11
|
+
class StatsDataNotAvailable < ::JayAPI::Errors::Error; end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module JayAPI
|
4
|
+
module Elasticsearch
|
5
|
+
class Stats
|
6
|
+
class Node
|
7
|
+
# Holds storage information related to one of the nodes in the
|
8
|
+
# Elasticsearch cluster.
|
9
|
+
class Storage
|
10
|
+
TOTAL_KEY = 'total_in_bytes'
|
11
|
+
FREE_KEY = 'free_in_bytes'
|
12
|
+
AVAILABLE_KEY = 'available_in_bytes'
|
13
|
+
|
14
|
+
# @param [Hash] data Data about the Node's storage.
|
15
|
+
def initialize(data)
|
16
|
+
@data = data
|
17
|
+
end
|
18
|
+
|
19
|
+
# @return [Integer] The total size of the storage (in bytes)
|
20
|
+
def total
|
21
|
+
@total ||= data[TOTAL_KEY]
|
22
|
+
end
|
23
|
+
|
24
|
+
# @return [Integer] The total number of bytes that are free on the
|
25
|
+
# node.
|
26
|
+
def free
|
27
|
+
@free ||= data[FREE_KEY]
|
28
|
+
end
|
29
|
+
|
30
|
+
# @return [Integer] The total number of bytes that are available on
|
31
|
+
# the node. In general this is equal to #free, but not always.
|
32
|
+
def available
|
33
|
+
@available ||= data[AVAILABLE_KEY]
|
34
|
+
end
|
35
|
+
|
36
|
+
# @return [self] A new instance of the class with the added storage of
|
37
|
+
# the receiver and +other+.
|
38
|
+
def +(other)
|
39
|
+
raise ArgumentError, "Cannot add #{self.class} and #{other.class} together" unless other.is_a?(self.class)
|
40
|
+
|
41
|
+
self.class.new(
|
42
|
+
TOTAL_KEY => total + other.total,
|
43
|
+
FREE_KEY => free + other.free,
|
44
|
+
AVAILABLE_KEY => available + other.available
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
attr_reader :data
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'errors/stats_data_not_available'
|
4
|
+
require_relative 'node/storage'
|
5
|
+
|
6
|
+
module JayAPI
|
7
|
+
module Elasticsearch
|
8
|
+
class Stats
|
9
|
+
# Holds information about one of the nodes in the Elasticsearch cluster.
|
10
|
+
class Node
|
11
|
+
attr_reader :name
|
12
|
+
|
13
|
+
# @param [String] name The name of the node.
|
14
|
+
# @param [Hash] data Information about the node.
|
15
|
+
def initialize(name, data)
|
16
|
+
@name = name
|
17
|
+
@data = data
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [JayAPI::Elasticsearch::Stats::Node::Storage] Storage
|
21
|
+
# information about the node.
|
22
|
+
# @raise [JayAPI::Elasticsearch::Stats::Errors::StatsDataNotAvailable]
|
23
|
+
# If there is no storage information for the node.
|
24
|
+
def storage
|
25
|
+
@storage ||= ::JayAPI::Elasticsearch::Stats::Node::Storage.new(fs_totals)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
attr_reader :data
|
31
|
+
|
32
|
+
# @return [Hash] Aggregated information about the +Node+'s
|
33
|
+
# filesystem.
|
34
|
+
# @raise [JayAPI::Elasticsearch::Stats::Errors::StatsDataNotAvailable]
|
35
|
+
# If there is no filesystem information for the node.
|
36
|
+
def fs_totals
|
37
|
+
@fs_totals ||= data.dig('fs', 'total') || raise(
|
38
|
+
::JayAPI::Elasticsearch::Stats::Errors::StatsDataNotAvailable,
|
39
|
+
"Filesystem data not available for node #{name}"
|
40
|
+
)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'forwardable'
|
4
|
+
|
5
|
+
require_relative 'node'
|
6
|
+
|
7
|
+
module JayAPI
|
8
|
+
module Elasticsearch
|
9
|
+
class Stats
|
10
|
+
# Provides access to the list of nodes returned by Elasticsearch's Stats API
|
11
|
+
class Nodes
|
12
|
+
extend Forwardable
|
13
|
+
|
14
|
+
def_delegator :nodes, :size
|
15
|
+
|
16
|
+
# @param [Hash] nodes Information about the nodes in the Elasticsearch
|
17
|
+
# cluster.
|
18
|
+
def initialize(nodes)
|
19
|
+
@nodes = nodes
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [Enumerator::Lazy<JayAPI::Elasticsearch::Stats::Node>] A lazy
|
23
|
+
# enumerator of +Node+ objects, one for each of the nodes.
|
24
|
+
def all
|
25
|
+
@all ||= with_lazy_instantiation { nodes }
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
attr_reader :nodes
|
31
|
+
|
32
|
+
def build_node(args)
|
33
|
+
::JayAPI::Elasticsearch::Stats::Node.new(*args)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Calls the given block and turns its return value into a lazy
|
37
|
+
# enumerator that instantiates a +Node+ object for each of the
|
38
|
+
# elements of the collection returned by the block.
|
39
|
+
# @return [Enumerator::Lazy<JayAPI::Elasticsearch::Stats::Node>]
|
40
|
+
def with_lazy_instantiation(&block)
|
41
|
+
block.call.lazy.map(&method(:build_node))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
require_relative 'stats/index'
|
4
4
|
require_relative 'stats/indices'
|
5
|
+
require_relative 'stats/node'
|
6
|
+
require_relative 'stats/nodes'
|
5
7
|
|
6
8
|
module JayAPI
|
7
9
|
module Elasticsearch
|
@@ -21,19 +23,37 @@ module JayAPI
|
|
21
23
|
# to the Statistics API endpoint fails.
|
22
24
|
def indices
|
23
25
|
# DO NOT MEMOIZE! Leave it to the caller.
|
24
|
-
::JayAPI::Elasticsearch::Stats::Indices.new(
|
26
|
+
::JayAPI::Elasticsearch::Stats::Indices.new(indices_stats['indices'])
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [JayAPI::Elasticsearch::Stats::Nodes] Information about the
|
30
|
+
# nodes that make up the Elasticsearch cluster.
|
31
|
+
# @raise [Elasticsearch::Transport::Transport::ServerError] If the request
|
32
|
+
# to the Statistics API endpoint fails.
|
33
|
+
def nodes
|
34
|
+
# DO NOT MEMOIZE! Leave it to the caller.
|
35
|
+
::JayAPI::Elasticsearch::Stats::Nodes.new(nodes_stats['nodes'])
|
25
36
|
end
|
26
37
|
|
27
38
|
private
|
28
39
|
|
29
|
-
# @return [Hash] The Hash with the statistics returned by
|
30
|
-
# Elasticsearch cluster.
|
40
|
+
# @return [Hash] The Hash with the index-related statistics returned by
|
41
|
+
# the Elasticsearch cluster.
|
31
42
|
# @raise [Elasticsearch::Transport::Transport::ServerError] If the
|
32
43
|
# request fails.
|
33
|
-
def
|
44
|
+
def indices_stats
|
34
45
|
# DO NOT MEMOIZE! Leave it to the caller.
|
35
46
|
transport_client.indices.stats
|
36
47
|
end
|
48
|
+
|
49
|
+
# @return [Hash] The Hash with the node-related statistics returned by the
|
50
|
+
# Elasticsearch cluster.
|
51
|
+
# @raise [Elasticsearch::Transport::Transport::ServerError] If the
|
52
|
+
# request fails.
|
53
|
+
def nodes_stats
|
54
|
+
# DO NOT MEMOIZE! Leave it to the caller.
|
55
|
+
transport_client.nodes.stats
|
56
|
+
end
|
37
57
|
end
|
38
58
|
end
|
39
59
|
end
|
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: 28.
|
4
|
+
version: 28.2.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: 2025-05-
|
12
|
+
date: 2025-05-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -172,8 +172,12 @@ files:
|
|
172
172
|
- lib/jay_api/elasticsearch/response.rb
|
173
173
|
- lib/jay_api/elasticsearch/search_after_results.rb
|
174
174
|
- lib/jay_api/elasticsearch/stats.rb
|
175
|
+
- lib/jay_api/elasticsearch/stats/errors/stats_data_not_available.rb
|
175
176
|
- lib/jay_api/elasticsearch/stats/index.rb
|
176
177
|
- lib/jay_api/elasticsearch/stats/indices.rb
|
178
|
+
- lib/jay_api/elasticsearch/stats/node.rb
|
179
|
+
- lib/jay_api/elasticsearch/stats/node/storage.rb
|
180
|
+
- lib/jay_api/elasticsearch/stats/nodes.rb
|
177
181
|
- lib/jay_api/elasticsearch/tasks.rb
|
178
182
|
- lib/jay_api/elasticsearch/time.rb
|
179
183
|
- lib/jay_api/errors/configuration_error.rb
|