elasticgraph-support 0.18.0.4 → 0.19.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/elasticgraph-support.gemspec +1 -1
- data/lib/elastic_graph/constants.rb +40 -1
- data/lib/elastic_graph/errors.rb +84 -0
- data/lib/elastic_graph/support/faraday_middleware/msearch_using_get_instead_of_post.rb +1 -0
- data/lib/elastic_graph/support/faraday_middleware/support_timeouts.rb +4 -3
- data/lib/elastic_graph/support/from_yaml_file.rb +3 -0
- data/lib/elastic_graph/support/graphql_formatter.rb +2 -0
- data/lib/elastic_graph/support/hash_util.rb +1 -0
- data/lib/elastic_graph/support/logger.rb +6 -2
- data/lib/elastic_graph/support/monotonic_clock.rb +2 -0
- data/lib/elastic_graph/support/threading.rb +1 -0
- data/lib/elastic_graph/support/time_set.rb +2 -0
- data/lib/elastic_graph/support/time_util.rb +1 -0
- data/lib/elastic_graph/support/untyped_encoder.rb +2 -0
- data/lib/elastic_graph/version.rb +1 -1
- metadata +21 -14
- data/lib/elastic_graph/error.rb +0 -99
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a193352b5ff270c94cbc560947d3cd95f447b0ae382aa01776edc55979fbffc
|
4
|
+
data.tar.gz: 2c641e634b2f3ce460215a0ef3d6ec34d4552ebc020ba7971ac1ae0b2ee9b9e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18027b60fd812f32fcf60b94ff40a3883a374ec105bd8dd2c35f503cf429ff81dfb58463f8943fa87139e57797bf740fdfcb89e75df33dd8069a4da7fdf1454f
|
7
|
+
data.tar.gz: 92cdf122aa05b9feb9a4077429537c9a74d5df61e73f50704530e58814adb54a1c80360c5e0189e033e3fae8ffa463d7b4db63f491d56db5f54653d75c663a66
|
@@ -18,6 +18,6 @@ ElasticGraphGemspecHelper.define_elasticgraph_gem(gemspec_file: __FILE__, catego
|
|
18
18
|
# https://github.com/aws/aws-lambda-ruby-runtime-interface-client/issues/33
|
19
19
|
spec.add_dependency "logger", "~> 1.6", ">= 1.6.1"
|
20
20
|
|
21
|
-
spec.add_development_dependency "faraday", "~> 2.
|
21
|
+
spec.add_development_dependency "faraday", "~> 2.12"
|
22
22
|
spec.add_development_dependency "rake", "~> 13.2"
|
23
23
|
end
|
@@ -6,18 +6,23 @@
|
|
6
6
|
#
|
7
7
|
# frozen_string_literal: true
|
8
8
|
|
9
|
-
#
|
9
|
+
# Root namespace for all ElasticGraph code.
|
10
10
|
module ElasticGraph
|
11
|
+
# Here we enumerate constants that are used from multiple places in the code.
|
12
|
+
|
11
13
|
# The datastore date format used by ElasticGraph. Matches ISO-8601/RFC-3339.
|
12
14
|
# See https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html#built-in-date-formats
|
15
|
+
# @private
|
13
16
|
DATASTORE_DATE_FORMAT = "strict_date"
|
14
17
|
|
15
18
|
# The datastore date time format used by ElasticGraph. Matches ISO-8601/RFC-3339.
|
16
19
|
# See https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html#built-in-date-formats
|
20
|
+
# @private
|
17
21
|
DATASTORE_DATE_TIME_FORMAT = "strict_date_time"
|
18
22
|
|
19
23
|
# HTTP header that ElasticGraph HTTP implementations (e.g. elasticgraph-rack, elasticgraph-lambda)
|
20
24
|
# look at to determine a client-specified request timeout.
|
25
|
+
# @private
|
21
26
|
TIMEOUT_MS_HEADER = "ElasticGraph-Request-Timeout-Ms"
|
22
27
|
|
23
28
|
# Min/max values for the `Int` type.
|
@@ -27,19 +32,25 @@ module ElasticGraph
|
|
27
32
|
# > than or equal to 2^31, a field error should be raised.
|
28
33
|
#
|
29
34
|
# (from http://spec.graphql.org/June2018/#sec-Int)
|
35
|
+
# @private
|
30
36
|
INT_MIN = -(2**31).to_int
|
37
|
+
# @private
|
31
38
|
INT_MAX = -INT_MIN - 1
|
32
39
|
|
33
40
|
# Min/max values for our `JsonSafeLong` type.
|
34
41
|
# Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
|
42
|
+
# @private
|
35
43
|
JSON_SAFE_LONG_MIN = -((2**53) - 1).to_int
|
44
|
+
# @private
|
36
45
|
JSON_SAFE_LONG_MAX = -JSON_SAFE_LONG_MIN
|
37
46
|
|
38
47
|
# Min/max values for our `LongString` type.
|
39
48
|
# This range is derived from the Elasticsearch docs on its longs:
|
40
49
|
# > A signed 64-bit integer with a minimum value of -2^63 and a maximum value of 2^63 - 1.
|
41
50
|
# (from https://www.elastic.co/guide/en/elasticsearch/reference/current/number.html)
|
51
|
+
# @private
|
42
52
|
LONG_STRING_MIN = -(2**63).to_int
|
53
|
+
# @private
|
43
54
|
LONG_STRING_MAX = -LONG_STRING_MIN - 1
|
44
55
|
|
45
56
|
# When indexing large string values into the datastore, we've observed errors like:
|
@@ -52,6 +63,7 @@ module ElasticGraph
|
|
52
63
|
# Note that it's a byte limit, but JSON schema's maxLength is a limit on the number of characters.
|
53
64
|
# UTF8 uses up to 4 bytes per character so to guard against a maliciously crafted payload, we limit
|
54
65
|
# the length to a quarter of 32766.
|
66
|
+
# @private
|
55
67
|
DEFAULT_MAX_KEYWORD_LENGTH = 32766 / 4
|
56
68
|
|
57
69
|
# Strings indexed as `text` can be much larger than `keyword` fields. In fact, there's no limitation
|
@@ -65,9 +77,11 @@ module ElasticGraph
|
|
65
77
|
# is on the overall payload size, and not on the size of one field. Given that, there's not really a
|
66
78
|
# discrete value we can use for the max length that guarantees successful indexing. But we know that
|
67
79
|
# values larger than this will fail, so this is the limit we use.
|
80
|
+
# @private
|
68
81
|
DEFAULT_MAX_TEXT_LENGTH = 100 * (2**20).to_int
|
69
82
|
|
70
83
|
# The name of the JSON schema definition for the ElasticGraph event envelope.
|
84
|
+
# @private
|
71
85
|
EVENT_ENVELOPE_JSON_SCHEMA_NAME = "ElasticGraphEventEnvelope"
|
72
86
|
|
73
87
|
# For some queries, we wind up needing a pagination cursor for a collection
|
@@ -76,23 +90,32 @@ module ElasticGraph
|
|
76
90
|
# Ideally, we want this to be a value that could never be produced by our normal
|
77
91
|
# cursor encoding logic. This cursor is encoded from data that includes a UUID,
|
78
92
|
# which we can trust is unique.
|
93
|
+
# @private
|
79
94
|
SINGLETON_CURSOR = "eyJ1dWlkIjoiZGNhMDJkMjAtYmFlZS00ZWU5LWEwMjctZmVlY2UwYTZkZTNhIn0="
|
80
95
|
|
81
96
|
# Schema artifact file names.
|
97
|
+
# @private
|
82
98
|
GRAPHQL_SCHEMA_FILE = "schema.graphql"
|
99
|
+
# @private
|
83
100
|
JSON_SCHEMAS_FILE = "json_schemas.yaml"
|
101
|
+
# @private
|
84
102
|
DATASTORE_CONFIG_FILE = "datastore_config.yaml"
|
103
|
+
# @private
|
85
104
|
RUNTIME_METADATA_FILE = "runtime_metadata.yaml"
|
86
105
|
|
87
106
|
# Name for directory that contains versioned json_schemas files.
|
107
|
+
# @private
|
88
108
|
JSON_SCHEMAS_BY_VERSION_DIRECTORY = "json_schemas_by_version"
|
89
109
|
# Name for field in json schemas files that represents schema "version".
|
110
|
+
# @private
|
90
111
|
JSON_SCHEMA_VERSION_KEY = "json_schema_version"
|
91
112
|
|
92
113
|
# String that goes in the middle of a rollover index name, used to mark it as a rollover
|
93
114
|
# index (and split on to parse a rollover index name).
|
115
|
+
# @private
|
94
116
|
ROLLOVER_INDEX_INFIX_MARKER = "_rollover__"
|
95
117
|
|
118
|
+
# @private
|
96
119
|
DERIVED_INDEX_FAILURE_MESSAGE_PREAMBLE = "Derived index update failed due to bad input data"
|
97
120
|
|
98
121
|
# The current id of our static `index_data` update script. Verified by a test so you can count
|
@@ -101,6 +124,7 @@ module ElasticGraph
|
|
101
124
|
# defined) being available, since that gem is usually only used in development.
|
102
125
|
#
|
103
126
|
# Note: this constant is automatically kept up-to-date by our `schema_artifacts:dump` rake task.
|
127
|
+
# @private
|
104
128
|
INDEX_DATA_UPDATE_SCRIPT_ID = "update_index_data_d577eb4b07ee3c53b59f2f6d6c7b2413"
|
105
129
|
|
106
130
|
# The id of the old version of the update data script before ElasticGraph v0.9. For now, we are maintaining
|
@@ -108,6 +132,7 @@ module ElasticGraph
|
|
108
132
|
# upon this id.
|
109
133
|
#
|
110
134
|
# TODO: Drop this when we no longer need to maintain backwards-compatibility.
|
135
|
+
# @private
|
111
136
|
OLD_INDEX_DATA_UPDATE_SCRIPT_ID = "update_index_data_9b97090d5c97c4adc82dc7f4c2b89bc5"
|
112
137
|
|
113
138
|
# When an update script has a no-op result we often want to communicate more information about
|
@@ -116,6 +141,7 @@ module ElasticGraph
|
|
116
141
|
# custom exception classes. To allow elasticgraph-indexer to detect that the script "failed" due
|
117
142
|
# to a no-op (rather than a true failure) we include this common preamble in the exception message
|
118
143
|
# thrown from our update scripts for the no-op case.
|
144
|
+
# @private
|
119
145
|
UPDATE_WAS_NOOP_MESSAGE_PREAMBLE = "ElasticGraph update was a no-op: "
|
120
146
|
|
121
147
|
# The name used to refer to a document's own/primary source event (that is, the event that has a `type`
|
@@ -123,10 +149,12 @@ module ElasticGraph
|
|
123
149
|
# defined via the `relates_to_one`/`relates_to_many` APIs. The GraphQL spec reserves the double-underscore
|
124
150
|
# prefix on field names, which means that users cannot define a relationship named `__self` via the
|
125
151
|
# `relates_to_one`/`relates_to_many` APIs.
|
152
|
+
# @private
|
126
153
|
SELF_RELATIONSHIP_NAME = "__self"
|
127
154
|
|
128
155
|
# This regex aligns with the datastore format of HH:mm:ss || HH:mm:ss.S || HH:mm:ss.SS || HH:mm:ss.SSS
|
129
156
|
# See https://rubular.com/r/NHjBWrpZvzOTJO for examples.
|
157
|
+
# @private
|
130
158
|
VALID_LOCAL_TIME_REGEX = /\A(([0-1][0-9])|(2[0-3])):[0-5][0-9]:[0-5][0-9](\.[0-9]{1,3})?\z/
|
131
159
|
|
132
160
|
# `VALID_LOCAL_TIME_REGEX`, expressed as a JSON schema pattern. JSON schema supports a subset of
|
@@ -136,6 +164,7 @@ module ElasticGraph
|
|
136
164
|
# For more info, see:
|
137
165
|
# https://json-schema.org/understanding-json-schema/reference/regular_expressions.html
|
138
166
|
# http://www.rexegg.com/regex-anchors.html
|
167
|
+
# @private
|
139
168
|
VALID_LOCAL_TIME_JSON_SCHEMA_PATTERN = VALID_LOCAL_TIME_REGEX.source.sub(/\A\\A/, "^").sub(/\\z\z/, "$")
|
140
169
|
|
141
170
|
# Special hidden field defined in an index where we store the count of elements in each list field.
|
@@ -144,6 +173,7 @@ module ElasticGraph
|
|
144
173
|
#
|
145
174
|
# The field name has a leading `__` because the GraphQL spec reserves that prefix for its own use,
|
146
175
|
# and we can therefore assume that no GraphQL fields have this name.
|
176
|
+
# @private
|
147
177
|
LIST_COUNTS_FIELD = "__counts"
|
148
178
|
|
149
179
|
# Character used to separate parts of a field path for the keys in the special `__counts`
|
@@ -158,6 +188,7 @@ module ElasticGraph
|
|
158
188
|
# (for the parent list count) and an object containing counts of its child lists.
|
159
189
|
#
|
160
190
|
# By using `|` instead of `.`, we avoid this problem.
|
191
|
+
# @private
|
161
192
|
LIST_COUNTS_FIELD_PATH_KEY_SEPARATOR = "|"
|
162
193
|
|
163
194
|
# The set of datastore field types which have no `properties` in the mapping, but which
|
@@ -165,6 +196,7 @@ module ElasticGraph
|
|
165
196
|
#
|
166
197
|
# I built this list by auditing the full list of index field mapping types:
|
167
198
|
# https://www.elastic.co/guide/en/elasticsearch/reference/8.9/mapping-types.html
|
199
|
+
# @private
|
168
200
|
DATASTORE_PROPERTYLESS_OBJECT_TYPES = [
|
169
201
|
"aggregate_metric_double", # https://www.elastic.co/guide/en/elasticsearch/reference/8.9/aggregate-metric-double.html
|
170
202
|
"completion", # https://www.elastic.co/guide/en/elasticsearch/reference/8.9/search-suggesters.html#completion-suggester
|
@@ -184,19 +216,24 @@ module ElasticGraph
|
|
184
216
|
# http://spec.graphql.org/June2018/#sec-Names
|
185
217
|
#
|
186
218
|
# ...however, it allows additional non-valid characters before and after it.
|
219
|
+
# @private
|
187
220
|
GRAPHQL_NAME_WITHIN_LARGER_STRING_PATTERN = /[_A-Za-z][_0-9A-Za-z]*/
|
188
221
|
|
189
222
|
# This pattern exactly matches a valid GraphQL name, with no extra characters allowed before or after.
|
223
|
+
# @private
|
190
224
|
GRAPHQL_NAME_PATTERN = /\A#{GRAPHQL_NAME_WITHIN_LARGER_STRING_PATTERN}\z/
|
191
225
|
|
192
226
|
# Description in English of the requirements for GraphQL names. (Used in multiple error messages).
|
227
|
+
# @private
|
193
228
|
GRAPHQL_NAME_VALIDITY_DESCRIPTION = "Names are limited to ASCII alphanumeric characters (plus underscore), and cannot start with a number."
|
194
229
|
|
195
230
|
# The standard set of scalars that are defined by the GraphQL spec:
|
196
231
|
# https://spec.graphql.org/October2021/#sec-Scalars
|
232
|
+
# @private
|
197
233
|
STOCK_GRAPHQL_SCALARS = %w[Boolean Float ID Int String].to_set.freeze
|
198
234
|
|
199
235
|
# The current variant of JSON schema that we use.
|
236
|
+
# @private
|
200
237
|
JSON_META_SCHEMA = "http://json-schema.org/draft-07/schema#"
|
201
238
|
|
202
239
|
# Filter the bulk response payload with a comma separated list using dot notation.
|
@@ -205,6 +242,7 @@ module ElasticGraph
|
|
205
242
|
# Note: anytime you change this constant, be sure to check all the comments in the unit specs that mention this constant.
|
206
243
|
# When stubbing a datastore client test double, it doesn't respect this filtering obviously, so it's up to us
|
207
244
|
# to accurately mimic the filtering in our stubbed responses.
|
245
|
+
# @private
|
208
246
|
DATASTORE_BULK_FILTER_PATH = [
|
209
247
|
# The key under `items` names the type of operation (e.g. `index` or `update`) and
|
210
248
|
# we use a `*` for it since we always use that key, regardless of which operation it is.
|
@@ -212,6 +250,7 @@ module ElasticGraph
|
|
212
250
|
].join(",")
|
213
251
|
|
214
252
|
# HTTP header set by `elasticgraph-graphql_lambda` to indicate the AWS ARN of the caller.
|
253
|
+
# @private
|
215
254
|
GRAPHQL_LAMBDA_AWS_ARN_HEADER = "X-AWS-LAMBDA-CALLER-ARN"
|
216
255
|
|
217
256
|
# TODO(steep): it complains about `define_schema` not being defined but it is defined
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# Copyright 2024 Block, Inc.
|
2
|
+
#
|
3
|
+
# Use of this source code is governed by an MIT-style
|
4
|
+
# license that can be found in the LICENSE file or at
|
5
|
+
# https://opensource.org/licenses/MIT.
|
6
|
+
#
|
7
|
+
# frozen_string_literal: true
|
8
|
+
|
9
|
+
module ElasticGraph
|
10
|
+
# @private
|
11
|
+
module Errors
|
12
|
+
class Error < StandardError
|
13
|
+
end
|
14
|
+
|
15
|
+
class CursorEncoderError < Error
|
16
|
+
end
|
17
|
+
|
18
|
+
class InvalidSortFieldsError < CursorEncoderError
|
19
|
+
end
|
20
|
+
|
21
|
+
class InvalidCursorError < CursorEncoderError
|
22
|
+
end
|
23
|
+
|
24
|
+
class CursorEncodingError < CursorEncoderError
|
25
|
+
end
|
26
|
+
|
27
|
+
class CountUnavailableError < Error
|
28
|
+
end
|
29
|
+
|
30
|
+
class InvalidArgumentValueError < Error
|
31
|
+
end
|
32
|
+
|
33
|
+
class InvalidMergeError < Error
|
34
|
+
end
|
35
|
+
|
36
|
+
class SchemaError < Error
|
37
|
+
end
|
38
|
+
|
39
|
+
class InvalidGraphQLNameError < SchemaError
|
40
|
+
end
|
41
|
+
|
42
|
+
class NotFoundError < Error
|
43
|
+
end
|
44
|
+
|
45
|
+
class SearchFailedError < Error
|
46
|
+
end
|
47
|
+
|
48
|
+
class RequestExceededDeadlineError < SearchFailedError
|
49
|
+
end
|
50
|
+
|
51
|
+
class IdentifyDocumentVersionsFailedError < Error
|
52
|
+
end
|
53
|
+
|
54
|
+
class IndexOperationError < Error
|
55
|
+
end
|
56
|
+
|
57
|
+
class ClusterOperationError < Error
|
58
|
+
end
|
59
|
+
|
60
|
+
class InvalidExtensionError < Error
|
61
|
+
end
|
62
|
+
|
63
|
+
class ConfigError < Error
|
64
|
+
end
|
65
|
+
|
66
|
+
class ConfigSettingNotSetError < ConfigError
|
67
|
+
end
|
68
|
+
|
69
|
+
class InvalidScriptDirectoryError < Error
|
70
|
+
end
|
71
|
+
|
72
|
+
class MissingSchemaArtifactError < Error
|
73
|
+
end
|
74
|
+
|
75
|
+
class S3OperationFailedError < Error
|
76
|
+
end
|
77
|
+
|
78
|
+
class MessageIdsMissingError < Error
|
79
|
+
end
|
80
|
+
|
81
|
+
class BadDatastoreRequest < Error
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -8,6 +8,7 @@
|
|
8
8
|
|
9
9
|
module ElasticGraph
|
10
10
|
module Support
|
11
|
+
# @private
|
11
12
|
module FaradayMiddleware
|
12
13
|
# Custom Faraday middleware that forces `msearch` calls to use an HTTP GET instead of an HTTP POST. While not
|
13
14
|
# necessary, it preserves a useful property: all "read" calls made by ElasticGraph use an HTTP GET, and HTTP POST
|
@@ -7,10 +7,11 @@
|
|
7
7
|
# frozen_string_literal: true
|
8
8
|
|
9
9
|
require "elastic_graph/constants"
|
10
|
-
require "elastic_graph/
|
10
|
+
require "elastic_graph/errors"
|
11
11
|
|
12
12
|
module ElasticGraph
|
13
13
|
module Support
|
14
|
+
# @private
|
14
15
|
module FaradayMiddleware
|
15
16
|
# Faraday supports specifying a timeout at both the client level (when building the Faraday connection) or on a
|
16
17
|
# per-request basis. We want to specify it on a per-request basis, but unfortunately, the Elasticsearch/OpenSearch
|
@@ -23,12 +24,12 @@ module ElasticGraph
|
|
23
24
|
# @implements SupportTimeouts
|
24
25
|
def call(env)
|
25
26
|
if (timeout_ms = env.request_headers.delete(TIMEOUT_MS_HEADER))
|
26
|
-
env.request.timeout = timeout_ms / 1000.0
|
27
|
+
env.request.timeout = Integer(timeout_ms) / 1000.0
|
27
28
|
end
|
28
29
|
|
29
30
|
app.call(env)
|
30
31
|
rescue ::Faraday::TimeoutError
|
31
|
-
raise RequestExceededDeadlineError, "Datastore request exceeded timeout of #{timeout_ms} ms."
|
32
|
+
raise Errors::RequestExceededDeadlineError, "Datastore request exceeded timeout of #{timeout_ms} ms."
|
32
33
|
end
|
33
34
|
end
|
34
35
|
end
|
@@ -9,7 +9,10 @@
|
|
9
9
|
require "yaml"
|
10
10
|
|
11
11
|
module ElasticGraph
|
12
|
+
# Provides support utilities for the rest of the ElasticGraph gems. As such, it is not intended
|
13
|
+
# to provide public APIs for ElasticGraph users.
|
12
14
|
module Support
|
15
|
+
# @private
|
13
16
|
module FromYamlFile
|
14
17
|
# Factory method that will build an instance from the provided `yaml_file`.
|
15
18
|
# `datastore_client_customization_block:` can be passed to customize the datastore clients.
|
@@ -11,6 +11,8 @@ require "json"
|
|
11
11
|
module ElasticGraph
|
12
12
|
module Support
|
13
13
|
# Utility module that provides helper methods for generating well-formatted GraphQL syntax.
|
14
|
+
#
|
15
|
+
# @private
|
14
16
|
module GraphQLFormatter
|
15
17
|
# Formats the given hash as an argument list. If `args` is empty, returns an empty string.
|
16
18
|
# Otherwise, wraps the args list in parens. This allows the returned string to be appended
|
@@ -8,6 +8,7 @@
|
|
8
8
|
|
9
9
|
module ElasticGraph
|
10
10
|
module Support
|
11
|
+
# @private
|
11
12
|
class HashUtil
|
12
13
|
# Fetches a key from a hash (just like `Hash#fetch`) but with a more verbose error message when the key is not found.
|
13
14
|
# The error message indicates the available keys unlike `Hash#fetch`.
|
@@ -6,19 +6,21 @@
|
|
6
6
|
#
|
7
7
|
# frozen_string_literal: true
|
8
8
|
|
9
|
-
require "elastic_graph/
|
9
|
+
require "elastic_graph/errors"
|
10
10
|
require "json"
|
11
11
|
require "logger"
|
12
12
|
require "pathname"
|
13
13
|
|
14
14
|
module ElasticGraph
|
15
15
|
module Support
|
16
|
+
# @private
|
16
17
|
module Logger
|
17
18
|
# Builds a logger instance from the given parsed YAML config.
|
18
19
|
def self.from_parsed_yaml(parsed_yaml)
|
19
20
|
Factory.build(config: Config.from_parsed_yaml(parsed_yaml))
|
20
21
|
end
|
21
22
|
|
23
|
+
# @private
|
22
24
|
module Factory
|
23
25
|
def self.build(config:, device: nil)
|
24
26
|
::Logger.new(
|
@@ -29,6 +31,7 @@ module ElasticGraph
|
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
34
|
+
# @private
|
32
35
|
class JSONAwareFormatter
|
33
36
|
def initialize
|
34
37
|
@original_formatter = ::Logger::Formatter.new
|
@@ -40,6 +43,7 @@ module ElasticGraph
|
|
40
43
|
end
|
41
44
|
end
|
42
45
|
|
46
|
+
# @private
|
43
47
|
class Config < ::Data.define(
|
44
48
|
# Determines what severity level we log. Valid values are `DEBUG`, `INFO`, `WARN`,
|
45
49
|
# `ERROR`, `FATAL` and `UNKNOWN`.
|
@@ -65,7 +69,7 @@ module ElasticGraph
|
|
65
69
|
extra_keys = hash.keys - EXPECTED_KEYS
|
66
70
|
|
67
71
|
unless extra_keys.empty?
|
68
|
-
raise ConfigError, "Unknown `logger` config settings: #{extra_keys.join(", ")}"
|
72
|
+
raise Errors::ConfigError, "Unknown `logger` config settings: #{extra_keys.join(", ")}"
|
69
73
|
end
|
70
74
|
|
71
75
|
new(
|
@@ -9,6 +9,8 @@
|
|
9
9
|
module ElasticGraph
|
10
10
|
module Support
|
11
11
|
# A simple abstraction that provides a monotonic clock.
|
12
|
+
#
|
13
|
+
# @private
|
12
14
|
class MonotonicClock
|
13
15
|
# Returns an abstract "now" value in integer milliseconds, suitable for calculating
|
14
16
|
# a duration or deadline, without being impacted by leap seconds, etc.
|
@@ -20,6 +20,8 @@ module ElasticGraph
|
|
20
20
|
# - An open range: a range with only an upper or lower bound (but not the other).
|
21
21
|
# - A closed range: a range with an upper and lower bound.
|
22
22
|
# - An empty range: a range that contains no `::Time`s, by virtue of its bounds having no overlap.
|
23
|
+
#
|
24
|
+
# @private
|
23
25
|
class TimeSet < ::Data.define(:ranges)
|
24
26
|
# Factory method to construct a `TimeSet` using a range with the given bounds.
|
25
27
|
def self.of_range(gt: nil, gte: nil, lt: nil, lte: nil)
|
@@ -19,6 +19,8 @@ module ElasticGraph
|
|
19
19
|
# Note: change this class with care. Changing the behavior to make `encode` produce different strings may result
|
20
20
|
# in breaking queries if the `Untyped`s stored in the index were indexed using previous encoding logic.
|
21
21
|
# A backfill into the datastore will likely be required to avoid this issue.
|
22
|
+
#
|
23
|
+
# @private
|
22
24
|
module UntypedEncoder
|
23
25
|
# Encodes the given untyped value to a String so it can be indexed in a Elasticsearch/OpenSearch `keyword` field.
|
24
26
|
def self.encode(value)
|
metadata
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticgraph-support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.19.0.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Myron Marston
|
8
|
+
- Ben VandenBos
|
9
|
+
- Block Engineering
|
8
10
|
autorequire:
|
9
11
|
bindir: exe
|
10
12
|
cert_chain: []
|
11
|
-
date: 2024-
|
13
|
+
date: 2024-12-03 00:00:00.000000000 Z
|
12
14
|
dependencies:
|
13
15
|
- !ruby/object:Gem::Dependency
|
14
16
|
name: rubocop-factory_bot
|
@@ -44,42 +46,42 @@ dependencies:
|
|
44
46
|
requirements:
|
45
47
|
- - "~>"
|
46
48
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3.
|
49
|
+
version: '3.1'
|
48
50
|
type: :development
|
49
51
|
prerelease: false
|
50
52
|
version_requirements: !ruby/object:Gem::Requirement
|
51
53
|
requirements:
|
52
54
|
- - "~>"
|
53
55
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3.
|
56
|
+
version: '3.1'
|
55
57
|
- !ruby/object:Gem::Dependency
|
56
58
|
name: standard
|
57
59
|
requirement: !ruby/object:Gem::Requirement
|
58
60
|
requirements:
|
59
61
|
- - "~>"
|
60
62
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
63
|
+
version: 1.41.0
|
62
64
|
type: :development
|
63
65
|
prerelease: false
|
64
66
|
version_requirements: !ruby/object:Gem::Requirement
|
65
67
|
requirements:
|
66
68
|
- - "~>"
|
67
69
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.
|
70
|
+
version: 1.41.0
|
69
71
|
- !ruby/object:Gem::Dependency
|
70
72
|
name: steep
|
71
73
|
requirement: !ruby/object:Gem::Requirement
|
72
74
|
requirements:
|
73
75
|
- - "~>"
|
74
76
|
- !ruby/object:Gem::Version
|
75
|
-
version: '1.
|
77
|
+
version: '1.8'
|
76
78
|
type: :development
|
77
79
|
prerelease: false
|
78
80
|
version_requirements: !ruby/object:Gem::Requirement
|
79
81
|
requirements:
|
80
82
|
- - "~>"
|
81
83
|
- !ruby/object:Gem::Version
|
82
|
-
version: '1.
|
84
|
+
version: '1.8'
|
83
85
|
- !ruby/object:Gem::Dependency
|
84
86
|
name: coderay
|
85
87
|
requirement: !ruby/object:Gem::Requirement
|
@@ -134,14 +136,14 @@ dependencies:
|
|
134
136
|
requirements:
|
135
137
|
- - "~>"
|
136
138
|
- !ruby/object:Gem::Version
|
137
|
-
version: '0.
|
139
|
+
version: '0.13'
|
138
140
|
type: :development
|
139
141
|
prerelease: false
|
140
142
|
version_requirements: !ruby/object:Gem::Requirement
|
141
143
|
requirements:
|
142
144
|
- - "~>"
|
143
145
|
- !ruby/object:Gem::Version
|
144
|
-
version: '0.
|
146
|
+
version: '0.13'
|
145
147
|
- !ruby/object:Gem::Dependency
|
146
148
|
name: simplecov
|
147
149
|
requirement: !ruby/object:Gem::Requirement
|
@@ -196,14 +198,14 @@ dependencies:
|
|
196
198
|
requirements:
|
197
199
|
- - "~>"
|
198
200
|
- !ruby/object:Gem::Version
|
199
|
-
version: '2.
|
201
|
+
version: '2.12'
|
200
202
|
type: :development
|
201
203
|
prerelease: false
|
202
204
|
version_requirements: !ruby/object:Gem::Requirement
|
203
205
|
requirements:
|
204
206
|
- - "~>"
|
205
207
|
- !ruby/object:Gem::Version
|
206
|
-
version: '2.
|
208
|
+
version: '2.12'
|
207
209
|
- !ruby/object:Gem::Dependency
|
208
210
|
name: rake
|
209
211
|
requirement: !ruby/object:Gem::Requirement
|
@@ -229,7 +231,7 @@ files:
|
|
229
231
|
- README.md
|
230
232
|
- elasticgraph-support.gemspec
|
231
233
|
- lib/elastic_graph/constants.rb
|
232
|
-
- lib/elastic_graph/
|
234
|
+
- lib/elastic_graph/errors.rb
|
233
235
|
- lib/elastic_graph/support/faraday_middleware/msearch_using_get_instead_of_post.rb
|
234
236
|
- lib/elastic_graph/support/faraday_middleware/support_timeouts.rb
|
235
237
|
- lib/elastic_graph/support/from_yaml_file.rb
|
@@ -243,10 +245,15 @@ files:
|
|
243
245
|
- lib/elastic_graph/support/time_util.rb
|
244
246
|
- lib/elastic_graph/support/untyped_encoder.rb
|
245
247
|
- lib/elastic_graph/version.rb
|
246
|
-
homepage:
|
248
|
+
homepage: https://block.github.io/elasticgraph/
|
247
249
|
licenses:
|
248
250
|
- MIT
|
249
251
|
metadata:
|
252
|
+
bug_tracker_uri: https://github.com/block/elasticgraph/issues
|
253
|
+
changelog_uri: https://github.com/block/elasticgraph/releases/tag/v0.19.0.0.rc1
|
254
|
+
documentation_uri: https://block.github.io/elasticgraph/docs/main/
|
255
|
+
homepage_uri: https://block.github.io/elasticgraph/
|
256
|
+
source_code_uri: https://github.com/block/elasticgraph/tree/v0.19.0.0.rc1/elasticgraph-support
|
250
257
|
gem_category: core
|
251
258
|
post_install_message:
|
252
259
|
rdoc_options: []
|
data/lib/elastic_graph/error.rb
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
# Copyright 2024 Block, Inc.
|
2
|
-
#
|
3
|
-
# Use of this source code is governed by an MIT-style
|
4
|
-
# license that can be found in the LICENSE file or at
|
5
|
-
# https://opensource.org/licenses/MIT.
|
6
|
-
#
|
7
|
-
# frozen_string_literal: true
|
8
|
-
|
9
|
-
module ElasticGraph
|
10
|
-
class Error < StandardError
|
11
|
-
end
|
12
|
-
|
13
|
-
class CursorEncoderError < Error
|
14
|
-
end
|
15
|
-
|
16
|
-
class InvalidSortFieldsError < CursorEncoderError
|
17
|
-
end
|
18
|
-
|
19
|
-
class InvalidCursorError < CursorEncoderError
|
20
|
-
end
|
21
|
-
|
22
|
-
class CursorEncodingError < CursorEncoderError
|
23
|
-
end
|
24
|
-
|
25
|
-
class CountUnavailableError < Error
|
26
|
-
end
|
27
|
-
|
28
|
-
class InvalidArgumentValueError < Error
|
29
|
-
end
|
30
|
-
|
31
|
-
class InvalidAggregationKeyError < Error
|
32
|
-
end
|
33
|
-
|
34
|
-
class InvalidMergeError < Error
|
35
|
-
end
|
36
|
-
|
37
|
-
class QueryMergeError < Error
|
38
|
-
end
|
39
|
-
|
40
|
-
class SchemaError < Error
|
41
|
-
end
|
42
|
-
|
43
|
-
class InvalidGraphQLNameError < SchemaError
|
44
|
-
end
|
45
|
-
|
46
|
-
class NotFoundError < Error
|
47
|
-
end
|
48
|
-
|
49
|
-
class SearchFailedError < Error
|
50
|
-
end
|
51
|
-
|
52
|
-
class RequestExceededDeadlineError < SearchFailedError
|
53
|
-
end
|
54
|
-
|
55
|
-
class IdentifyDocumentVersionsFailedError < Error
|
56
|
-
end
|
57
|
-
|
58
|
-
class IndexOperationError < Error
|
59
|
-
end
|
60
|
-
|
61
|
-
class ClusterOperationError < Error
|
62
|
-
end
|
63
|
-
|
64
|
-
class InvalidEventIDError < Error
|
65
|
-
end
|
66
|
-
|
67
|
-
class UnsupportedOperationError < Error
|
68
|
-
end
|
69
|
-
|
70
|
-
class InvalidExtensionError < Error
|
71
|
-
end
|
72
|
-
|
73
|
-
class ConfigError < Error
|
74
|
-
end
|
75
|
-
|
76
|
-
class ConfigSettingNotSetError < ConfigError
|
77
|
-
end
|
78
|
-
|
79
|
-
class ConfigCannotBeMutatedError < ConfigError
|
80
|
-
end
|
81
|
-
|
82
|
-
class UnknownYAMLSettingError < ConfigError
|
83
|
-
end
|
84
|
-
|
85
|
-
class InvalidScriptDirectoryError < Error
|
86
|
-
end
|
87
|
-
|
88
|
-
class MissingSchemaArtifactError < Error
|
89
|
-
end
|
90
|
-
|
91
|
-
class S3OperationFailedError < Error
|
92
|
-
end
|
93
|
-
|
94
|
-
class MessageIdsMissingError < Error
|
95
|
-
end
|
96
|
-
|
97
|
-
class BadDatastoreRequest < Error
|
98
|
-
end
|
99
|
-
end
|