momento 0.5.1 → 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 +4 -4
- data/.release-please-manifest.json +1 -1
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +1 -1
- data/LICENSE.txt +1 -1
- data/README.md +5 -5
- data/examples/Gemfile +1 -1
- data/examples/example.rb +1 -1
- data/lib/momento/error/types.rb +56 -3
- data/lib/momento/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a434fab9ea18754adf07caa6329e54dae49850a0ffa062401c6a308828157f5
|
4
|
+
data.tar.gz: '08b8c45034679d3f4da9b65675b68815fe6e6b220d0a2ad226e2003b7593cd49'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30810c921986468ce2b088dea2ca544491c284a403995abf52eb5948e78823bf69ad4cc7dd8055c7ae49ae1997af991bb0d477005069930b94f0c548bf05da46
|
7
|
+
data.tar.gz: 5d7792f33d04eb303f7cb1f1f447434bb7d07a25edd36688a0510bd5d1a43d9a38d5a8a9e5463c748e337e019bd04e4224020c6c75e40ed60808f8e16d322b73
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [0.5.2](https://github.com/momentohq/client-sdk-ruby/compare/momento/v0.5.1...momento/v0.5.2) (2024-11-25)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* copyright info ([87d44d5](https://github.com/momentohq/client-sdk-ruby/commit/87d44d525041c4cd2e060fd63765ebb35904badb))
|
9
|
+
* copyright info ([#190](https://github.com/momentohq/client-sdk-ruby/issues/190)) ([47f3904](https://github.com/momentohq/client-sdk-ruby/commit/47f3904d39451957313f3306323e2c636945d971))
|
10
|
+
|
3
11
|
## [0.5.1](https://github.com/momentohq/client-sdk-ruby/compare/momento/v0.5.0...momento/v0.5.1) (2024-06-18)
|
4
12
|
|
5
13
|
|
data/Gemfile.lock
CHANGED
data/LICENSE.txt
CHANGED
@@ -186,7 +186,7 @@ file or class name and description of purpose be included on the
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
187
187
|
identification within third-party archives.
|
188
188
|
|
189
|
-
Copyright
|
189
|
+
Copyright 2024 Momento Inc.
|
190
190
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
192
192
|
you may not use this file except in compliance with the License.
|
data/README.md
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
<head>
|
2
|
-
<meta name="Momento
|
2
|
+
<meta name="Momento Client Library Documentation for Ruby" content="Momento client software development kit for Ruby">
|
3
3
|
</head>
|
4
4
|
<img src="https://docs.momentohq.com/img/momento-logo-forest.svg" alt="logo" width="400"/>
|
5
5
|
|
6
6
|
[](https://github.com/momentohq/standards-and-practices/blob/main/docs/momento-on-github.md)
|
7
7
|
[](https://github.com/momentohq/standards-and-practices/blob/main/docs/momento-on-github.md)
|
8
8
|
|
9
|
-
# Momento
|
9
|
+
# Momento Client Library for Ruby
|
10
10
|
|
11
11
|
Momento Cache is a fast, simple, pay-as-you-go caching solution without any of the operational overhead
|
12
|
-
required by traditional caching solutions. This repo contains the source code for the Momento
|
12
|
+
required by traditional caching solutions. This repo contains the source code for the Momento client library for Ruby.
|
13
13
|
|
14
14
|
To get started with Momento you will need a Momento Auth Token. You can get one from the [Momento Console](https://console.gomomento.com).
|
15
15
|
|
16
16
|
* Website: [https://www.gomomento.com/](https://www.gomomento.com/)
|
17
17
|
* Momento Documentation: [https://docs.momentohq.com/](https://docs.momentohq.com/)
|
18
18
|
* Getting Started: [https://docs.momentohq.com/getting-started](https://docs.momentohq.com/getting-started)
|
19
|
-
*
|
19
|
+
* Momento SDK Documentation for Ruby: [https://docs.momentohq.com/sdks/ruby](https://docs.momentohq.com/sdks/ruby)
|
20
20
|
* Discuss: [Momento Discord](https://discord.gg/3HkAKjUZGq)
|
21
21
|
|
22
22
|
# Momento Ruby SDK
|
@@ -74,7 +74,7 @@ credential_provider = Momento::CredentialProvider.from_env_var('MOMENTO_API_KEY'
|
|
74
74
|
# This is a reasonable configuration for dev work on a laptop.
|
75
75
|
configuration = Momento::Cache::Configurations::Laptop.latest
|
76
76
|
# This configuration might be better for a production where you want more aggressive timeouts
|
77
|
-
# configuration = Momento::Cache::
|
77
|
+
# configuration = Momento::Cache::Configurations::InRegion.latest
|
78
78
|
# To set a custom timeout, you can use the with_timeout method.
|
79
79
|
# configuration = configuration.with_timeout(10_000)
|
80
80
|
# To increase the number of TCP connections for a client where you expect a high volume of traffic,
|
data/examples/Gemfile
CHANGED
data/examples/example.rb
CHANGED
@@ -15,7 +15,7 @@ credential_provider = Momento::CredentialProvider.from_env_var('MOMENTO_API_KEY'
|
|
15
15
|
# This is a reasonable configuration for dev work on a laptop.
|
16
16
|
configuration = Momento::Cache::Configurations::Laptop.latest
|
17
17
|
# This configuration might be better for a production where you want more aggressive timeouts
|
18
|
-
# configuration = Momento::Cache::
|
18
|
+
# configuration = Momento::Cache::Configurations::InRegion.latest
|
19
19
|
# To set a custom timeout, you can use the with_timeout method.
|
20
20
|
# configuration = configuration.with_timeout(10_000)
|
21
21
|
# To increase the number of TCP connections for a client where you expect a high volume of traffic,
|
data/lib/momento/error/types.rb
CHANGED
@@ -146,16 +146,69 @@ module Momento
|
|
146
146
|
|
147
147
|
# Request rate exceeded the limits for this account.
|
148
148
|
class LimitExceededError < RuntimeError
|
149
|
-
|
149
|
+
attr_reader :details, :transport_details
|
150
|
+
|
151
|
+
def initialize(details = '', transport_details = nil)
|
152
|
+
super()
|
153
|
+
@details = details.to_s
|
154
|
+
@transport_details = transport_details
|
155
|
+
end
|
156
|
+
|
157
|
+
# Extract the error cause from metadata
|
158
|
+
def error_cause
|
159
|
+
metadata = transport_details&.grpc&.metadata || {}
|
160
|
+
metadata[:err] || 'unknown_error'
|
161
|
+
end
|
150
162
|
|
151
163
|
# (see Momento::Error#error_code)
|
152
164
|
def error_code
|
153
165
|
:LIMIT_EXCEEDED_ERROR
|
154
166
|
end
|
155
167
|
|
156
|
-
|
168
|
+
class ErrorMessages
|
169
|
+
TOPIC_SUBSCRIPTIONS_LIMIT_EXCEEDED = 'Topic subscriptions limit exceeded.'.freeze
|
170
|
+
OPERATIONS_RATE_LIMIT_EXCEEDED = 'Operations rate limit exceeded.'.freeze
|
171
|
+
THROUGHPUT_RATE_LIMIT_EXCEEDED = 'Throughput rate limit exceeded.'.freeze
|
172
|
+
REQUEST_SIZE_LIMIT_EXCEEDED = 'Request size limit exceeded.'.freeze
|
173
|
+
ITEM_SIZE_LIMIT_EXCEEDED = 'Item size limit exceeded.'.freeze
|
174
|
+
ELEMENT_SIZE_LIMIT_EXCEEDED = 'Element size limit exceeded.'.freeze
|
175
|
+
UNKNOWN_LIMIT_EXCEEDED = 'Limit exceeded for this account.'.freeze
|
176
|
+
|
177
|
+
# Map error causes to the corresponding message
|
178
|
+
ERROR_CAUSES = {
|
179
|
+
'topic_subscriptions_limit_exceeded' => TOPIC_SUBSCRIPTIONS_LIMIT_EXCEEDED,
|
180
|
+
'operations_rate_limit_exceeded' => OPERATIONS_RATE_LIMIT_EXCEEDED,
|
181
|
+
'throughput_rate_limit_exceeded' => THROUGHPUT_RATE_LIMIT_EXCEEDED,
|
182
|
+
'request_size_limit_exceeded' => REQUEST_SIZE_LIMIT_EXCEEDED,
|
183
|
+
'item_size_limit_exceeded' => ITEM_SIZE_LIMIT_EXCEEDED,
|
184
|
+
'element_size_limit_exceeded' => ELEMENT_SIZE_LIMIT_EXCEEDED
|
185
|
+
}.freeze
|
186
|
+
|
187
|
+
# Map substrings to the corresponding message
|
188
|
+
ERROR_SUBSTRINGS = {
|
189
|
+
'subscribers' => TOPIC_SUBSCRIPTIONS_LIMIT_EXCEEDED,
|
190
|
+
'operations' => OPERATIONS_RATE_LIMIT_EXCEEDED,
|
191
|
+
'throughput' => THROUGHPUT_RATE_LIMIT_EXCEEDED,
|
192
|
+
'request limit' => REQUEST_SIZE_LIMIT_EXCEEDED,
|
193
|
+
'item size' => ITEM_SIZE_LIMIT_EXCEEDED,
|
194
|
+
'element size' => ELEMENT_SIZE_LIMIT_EXCEEDED
|
195
|
+
}.freeze
|
196
|
+
end
|
197
|
+
|
198
|
+
# Generate the appropriate message based on the error cause or details
|
157
199
|
def message
|
158
|
-
|
200
|
+
# First, check for a direct match in the ERROR_CAUSES for the error cause
|
201
|
+
message = ErrorMessages::ERROR_CAUSES[error_cause]
|
202
|
+
|
203
|
+
# If no direct match for error cause, then check if any substring in details matches
|
204
|
+
if message.nil?
|
205
|
+
ErrorMessages::ERROR_SUBSTRINGS.each do |key, msg|
|
206
|
+
return msg if details.include?(key)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
# Return the default message if no match is found
|
211
|
+
message || ErrorMessages::UNKNOWN_LIMIT_EXCEEDED
|
159
212
|
end
|
160
213
|
end
|
161
214
|
|
data/lib/momento/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: momento
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Momento
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -321,7 +321,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
321
321
|
- !ruby/object:Gem::Version
|
322
322
|
version: '0'
|
323
323
|
requirements: []
|
324
|
-
rubygems_version: 3.5.
|
324
|
+
rubygems_version: 3.5.22
|
325
325
|
signing_key:
|
326
326
|
specification_version: 4
|
327
327
|
summary: Client for Momento Serverless Cache
|