sendmux-core 1.3.0 → 2.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f39dc569a3376fb13568b300d2cf22819cf1815894fac4f749cd8b0cd5622100
4
- data.tar.gz: bc14bfe99f7242ba965ff6f676d6fd2a4a7608b7530e0576ab4e3f7fce3fc29b
3
+ metadata.gz: f0be98427379d71222d6ceb17604c9441e7885bae84f1d638e9a553d512c0b10
4
+ data.tar.gz: d2f29306a04cce725da1af143e66721200f6bb3abfafd6fd395ad54bb1e41c8c
5
5
  SHA512:
6
- metadata.gz: a1976ba03f4693dee9b5b7a4dec6722a037d0ae2c170069bcda0e29d04a200ddcf399136bd2d3a3476c7c967d33e15ff2b71cb221adf5a3d59489e8d7a190a0d
7
- data.tar.gz: 9915b261526d42672bb55ed28be7bc5fe3171093eedc04b0cb5819de3c0e2a83ee372e9e73e21b748baab38d3358462820c3d8eda8468343dde5c513c36d5b9b
6
+ metadata.gz: 1bae7f265812971563803e64e6c448b38279744c18fd85d8653f932306153ea6ab20930a0730df36bbb874f7baa62161f1c0008876925ae021f0183486982b2e
7
+ data.tar.gz: 7545e0f237b64c38aac6b414e0ccf9c305f07d6d3f1c7b0b40833b58b26fd0045319be478f2d68c02e8652dd48ef47e696cf2b5a217c122dc9943754fa831db9
metadata CHANGED
@@ -1,35 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sendmux-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - Sendmux
7
+ - Qubrics
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-09-10 00:00:00.000000000 Z
10
+ date: 2026-11-19 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
- name: faraday
14
- requirement: !ruby/object:Gem::Requirement
15
- requirements:
16
- - - "~>"
17
- - !ruby/object:Gem::Version
18
- version: '2.0'
19
- type: :runtime
20
- prerelease: false
21
- version_requirements: !ruby/object:Gem::Requirement
22
- requirements:
23
- - - "~>"
24
- - !ruby/object:Gem::Version
25
- version: '2.0'
26
- - !ruby/object:Gem::Dependency
27
- name: faraday-retry
13
+ name: qubrics-core
28
14
  requirement: !ruby/object:Gem::Requirement
29
15
  requirements:
30
16
  - - ">="
31
17
  - !ruby/object:Gem::Version
32
- version: '2.4'
18
+ version: 2.0.0
33
19
  - - "<"
34
20
  - !ruby/object:Gem::Version
35
21
  version: '3.0'
@@ -39,35 +25,19 @@ dependencies:
39
25
  requirements:
40
26
  - - ">="
41
27
  - !ruby/object:Gem::Version
42
- version: '2.4'
28
+ version: 2.0.0
43
29
  - - "<"
44
30
  - !ruby/object:Gem::Version
45
31
  version: '3.0'
46
- email:
47
- - contact@sendmux.ai
32
+ description: Installs the required dependency.
48
33
  executables: []
49
34
  extensions: []
50
35
  extra_rdoc_files: []
51
- files:
52
- - CHANGELOG.md
53
- - LICENSE
54
- - README.md
55
- - lib/sendmux/core.rb
56
- - lib/sendmux/core/api_key_surface.rb
57
- - lib/sendmux/core/auth.rb
58
- - lib/sendmux/core/errors.rb
59
- - lib/sendmux/core/headers.rb
60
- - lib/sendmux/core/pagination.rb
61
- - lib/sendmux/core/retry.rb
62
- - lib/sendmux/core/retry_options.rb
63
- - lib/sendmux/core/version.rb
64
- homepage: https://github.com/Sendmux/sendmux-sdk
36
+ files: []
37
+ homepage: https://github.com/qubrics/qubrics-sdk
65
38
  licenses:
66
39
  - MIT
67
- metadata:
68
- homepage_uri: https://github.com/Sendmux/sendmux-sdk
69
- source_code_uri: https://github.com/Sendmux/sendmux-sdk/tree/main/packages/ruby/core
70
- changelog_uri: https://github.com/Sendmux/sendmux-sdk/blob/main/packages/ruby/core/CHANGELOG.md
40
+ metadata: {}
71
41
  rdoc_options: []
72
42
  require_paths:
73
43
  - lib
@@ -84,5 +54,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
54
  requirements: []
85
55
  rubygems_version: 3.6.2
86
56
  specification_version: 4
87
- summary: Shared core helpers for Sendmux Ruby SDK packages.
57
+ summary: Dependency-only package.
88
58
  test_files: []
data/CHANGELOG.md DELETED
@@ -1,34 +0,0 @@
1
- # Changelog
2
-
3
- ## [1.3.0](https://github.com/Sendmux/sendmux-sdk/compare/ruby-core/v1.2.0...ruby-core/v1.3.0) (2026-09-10)
4
-
5
-
6
- ### Features
7
-
8
- * add REST OAuth clients and CLI token lifecycle ([cc4a3aa](https://github.com/Sendmux/sendmux-sdk/commit/cc4a3aa6110378641418a94455ed5b9a986e65ff))
9
-
10
- ## [1.2.0](https://github.com/Sendmux/sendmux-sdk/compare/ruby-core/v1.1.0...ruby-core/v1.2.0) (2026-09-08)
11
-
12
-
13
- ### Features
14
-
15
- * add connection checks across SDKs, CLI and MCP ([77f449e](https://github.com/Sendmux/sendmux-sdk/commit/77f449e2c8cba49bc8bc84c49c35baa61120866a))
16
- * **sdk:** add connection checks across clients, CLI and MCP ([3e02c67](https://github.com/Sendmux/sendmux-sdk/commit/3e02c67dcab45e37dad7abbdd4c4e1bd0b1fbbe6))
17
-
18
- ## [1.1.0](https://github.com/Sendmux/sendmux-sdk/compare/ruby-core/v1.0.0...ruby-core/v1.1.0) (2026-07-01)
19
-
20
-
21
- ### Features
22
-
23
- * allow owner-approved agent tokens for sending ([9d1cb7d](https://github.com/Sendmux/sendmux-sdk/commit/9d1cb7df3df5aef1f59a4990dc087178ba3a7b21))
24
-
25
- ## 1.0.0 (2026-06-02)
26
-
27
-
28
- ### Features
29
-
30
- * **ruby:** add generated SDK packages ([f097fdf](https://github.com/Sendmux/sendmux-sdk/commit/f097fdf6afcbc2a048d9fdb1c9a669fff2a7ca4f))
31
-
32
- ## 1.0.0
33
-
34
- - Initial Ruby core helper package.
data/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Sendmux
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
data/README.md DELETED
@@ -1,100 +0,0 @@
1
- # sendmux-core
2
-
3
- [![Gem Version](https://badge.fury.io/rb/sendmux-core.svg)](https://rubygems.org/gems/sendmux-core)
4
- [![CI](https://github.com/Sendmux/sendmux-sdk/actions/workflows/ci.yml/badge.svg)](https://github.com/Sendmux/sendmux-sdk/actions/workflows/ci.yml)
5
- [![Licence: MIT](https://img.shields.io/badge/licence-MIT-blue.svg)](https://github.com/Sendmux/sendmux-sdk/blob/main/LICENSE)
6
-
7
- Shared authentication, retry, pagination, header, and error helpers for the Sendmux Ruby SDK packages.
8
-
9
- ## Documentation
10
-
11
- - Ruby SDK guide: https://sendmux.ai/docs/sdks/ruby
12
- - Source: https://github.com/Sendmux/sendmux-sdk/tree/main/packages/ruby/core
13
- - Changelog: https://github.com/Sendmux/sendmux-sdk/blob/main/packages/ruby/core/CHANGELOG.md
14
-
15
- ## Requirements
16
-
17
- - Ruby 3.1 or newer.
18
- - A Sendmux API key or REST OAuth access token when using a surface client.
19
-
20
- ## Installation
21
-
22
- ```sh
23
- gem install sendmux-core
24
- ```
25
-
26
- Or add it to your Gemfile:
27
-
28
- ```ruby
29
- gem "sendmux-core", "~> 1.0"
30
- ```
31
-
32
- ## Usage
33
-
34
- The core package is installed automatically by the surface gems, but it can also be used directly when you need shared helpers.
35
-
36
- ```ruby
37
- require "sendmux/core"
38
-
39
- surface = Sendmux::Core::Auth.assert_api_key_surface(
40
- ENV.fetch("SENDMUX_ROOT_KEY"),
41
- Sendmux::Core::ApiKeySurface::ROOT
42
- )
43
-
44
- puts surface
45
- ```
46
-
47
- Use `Sendmux::Core::ApiKeySurface::ROOT` for root-key management clients, `Sendmux::Core::ApiKeySurface::SENDING` for send-capable `smx_mbx_` keys or owner-approved Sending-resource `smx_agent_` tokens, and `Sendmux::Core::ApiKeySurface::MAILBOX` for mailbox-compatible credentials. Mailbox-compatible credentials can start with `smx_mbx_` or `smx_agent_`.
48
-
49
- Surface clients accept `access_token:` as a bare token or callable instead of `api_key:`. Token providers run before each request; the application owns token storage and refresh.
50
-
51
- ### Header helpers
52
-
53
- Generated Ruby operations accept option hashes. The header helpers return the option keys expected by those generated operations.
54
-
55
- ```ruby
56
- headers = Sendmux::Core::Headers.idempotency_key("idem_123")
57
- etag = Sendmux::Core::Headers.if_match('W/"etag"')
58
- conditional = Sendmux::Core::Headers.conditional(if_none_match: 'W/"cached"')
59
- ```
60
-
61
- ### Cursor pagination
62
-
63
- `Sendmux::Core.each_cursor` wraps any generated list call that accepts a cursor option and returns Sendmux pagination metadata.
64
-
65
- ```ruby
66
- pager = Sendmux::Core.each_cursor(lambda do |opts|
67
- mailbox_client.mailbox_api.mailbox_list_messages(opts.merge(limit: 50))
68
- end)
69
-
70
- pager.each do |message|
71
- puts message.id
72
- end
73
- ```
74
-
75
- ### Retries and errors
76
-
77
- Surface clients accept `Sendmux::Core::RetryOptions` and map generated errors to `Sendmux::Core::ApiError`.
78
-
79
- ```ruby
80
- retry_options = Sendmux::Core::RetryOptions.new(max_attempts: 4)
81
-
82
- begin
83
- # Pass retry_options: retry_options to any Sendmux surface client.
84
- # Call a generated operation here.
85
- nil
86
- rescue Sendmux::Core::ApiError => error
87
- warn "#{error.code}: #{error.message} (request #{error.request_id})"
88
- end
89
- ```
90
-
91
- Retries are enabled for safe requests and for idempotent `POST` requests that use an `Idempotency-Key`.
92
-
93
- ## Support
94
-
95
- - Documentation: https://sendmux.ai/docs
96
- - Contact: contact@sendmux.ai
97
-
98
- ## Licence
99
-
100
- MIT licence. See https://github.com/Sendmux/sendmux-sdk/blob/main/LICENSE.
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Sendmux
4
- module Core
5
- module ApiKeySurface
6
- ROOT = 'root'
7
- MAILBOX = 'mailbox'
8
- SENDING = 'sending'
9
- end
10
- end
11
- end
@@ -1,87 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'uri'
4
-
5
- module Sendmux
6
- module Core
7
- class Auth
8
- ROOT_PREFIX = 'smx_root_'
9
- MAILBOX_PREFIX = 'smx_mbx_'
10
- AGENT_PREFIX = 'smx_agent_'
11
-
12
- def self.configure_bearer(configuration, api_key, expected_surface, base_url: nil, access_token: nil)
13
- raise ArgumentError, 'Provide exactly one of api_key or access_token' if api_key.nil? == access_token.nil?
14
- unless configuration.respond_to?(:access_token=)
15
- raise ArgumentError, 'Generated configuration does not support bearer access tokens'
16
- end
17
-
18
- if api_key.nil?
19
- configure_access_token(configuration, access_token)
20
- else
21
- assert_api_key_surface(api_key, expected_surface)
22
- configuration.access_token = api_key
23
- configuration.access_token_getter = nil if configuration.respond_to?(:access_token_getter=)
24
- end
25
- configure_base_url(configuration, base_url) if base_url && !base_url.empty?
26
- configuration
27
- end
28
-
29
- def self.configure_access_token(configuration, access_token)
30
- if access_token.respond_to?(:call)
31
- configuration.access_token = nil
32
- configuration.access_token_getter = -> { validate_access_token(access_token.call) }
33
- else
34
- configuration.access_token = validate_access_token(access_token)
35
- configuration.access_token_getter = nil if configuration.respond_to?(:access_token_getter=)
36
- end
37
- end
38
-
39
- def self.validate_access_token(token)
40
- unless token.is_a?(String) && token.match?(%r{\A[A-Za-z0-9._~+/-]+=*\z})
41
- raise ArgumentError, 'Provide a valid bare access token'
42
- end
43
-
44
- token
45
- end
46
-
47
- def self.assert_api_key_surface(api_key, expected_surface)
48
- actual = surface_for(api_key)
49
- unless actual
50
- raise ArgumentError,
51
- "Sendmux API keys must start with #{ROOT_PREFIX}, #{MAILBOX_PREFIX}, or #{AGENT_PREFIX}"
52
- end
53
- return actual if compatible_surface?(api_key, actual, expected_surface)
54
-
55
- raise ArgumentError, "Expected a #{expected_surface} API key, received a #{actual} API key"
56
- end
57
-
58
- def self.compatible_surface?(api_key, actual, expected_surface)
59
- return true if actual == expected_surface
60
- return true if expected_surface == ApiKeySurface::SENDING &&
61
- (api_key.start_with?(MAILBOX_PREFIX) || api_key.start_with?(AGENT_PREFIX))
62
- return true if expected_surface == ApiKeySurface::MAILBOX && actual == ApiKeySurface::MAILBOX
63
-
64
- false
65
- end
66
-
67
- def self.surface_for(api_key)
68
- return ApiKeySurface::ROOT if api_key.start_with?(ROOT_PREFIX)
69
- return ApiKeySurface::MAILBOX if api_key.start_with?(MAILBOX_PREFIX)
70
- return ApiKeySurface::MAILBOX if api_key.start_with?(AGENT_PREFIX)
71
-
72
- nil
73
- end
74
-
75
- def self.configure_base_url(configuration, base_url)
76
- uri = URI(base_url)
77
- raise ArgumentError, 'base_url must include a scheme and host' unless uri.scheme && uri.host
78
-
79
- configuration.scheme = uri.scheme
80
- configuration.host = uri.host
81
- configuration.host += ":#{uri.port}" if uri.port && uri.port != uri.default_port
82
- configuration.base_path = uri.path
83
- configuration.ignore_operation_servers = true if configuration.respond_to?(:ignore_operation_servers=)
84
- end
85
- end
86
- end
87
- end
@@ -1,103 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'json'
4
-
5
- module Sendmux
6
- module Core
7
- class ApiError < StandardError
8
- attr_reader :status, :code, :request_id, :param, :retryable, :errors, :response_body, :response_headers
9
-
10
- def initialize(status:, code:, message:, retryable:, request_id: nil, param: nil, errors: nil,
11
- response_body: nil, response_headers: {})
12
- super(message)
13
- @status = status
14
- @code = code
15
- @request_id = request_id
16
- @param = param
17
- @retryable = retryable
18
- @errors = errors
19
- @response_body = response_body
20
- @response_headers = response_headers
21
- end
22
- end
23
-
24
- class ErrorMapper
25
- def self.map(error)
26
- return error if error.is_a?(ApiError)
27
-
28
- headers = normalise_headers(error.respond_to?(:response_headers) ? error.response_headers : {})
29
- body = error.respond_to?(:response_body) ? error.response_body : nil
30
- payload = payload_from(body)
31
- detail = hash_at(payload, 'error') || {}
32
- status = status_from(error)
33
-
34
- ApiError.new(
35
- status: status,
36
- code: string_at(detail, 'code') || 'api_error',
37
- message: string_at(detail, 'message') || error.message || 'Sendmux API request failed',
38
- retryable: retryable(detail, status),
39
- request_id: request_id(payload, headers),
40
- param: string_at(detail, 'param'),
41
- errors: detail['errors'],
42
- response_body: body,
43
- response_headers: headers
44
- )
45
- end
46
-
47
- def self.status_from(error)
48
- return error.code if error.respond_to?(:code) && error.code.is_a?(Integer) && error.code.positive?
49
-
50
- nil
51
- end
52
-
53
- def self.payload_from(body)
54
- return nil unless body.is_a?(String) && !body.empty?
55
-
56
- JSON.parse(body)
57
- rescue JSON::ParserError
58
- nil
59
- end
60
-
61
- def self.request_id(payload, headers)
62
- string_at(hash_at(payload, 'meta'), 'request_id') || header(headers, 'x-request-id')
63
- end
64
-
65
- def self.normalise_headers(headers)
66
- return {} unless headers.respond_to?(:each)
67
-
68
- headers.each_with_object({}) do |(key, value), result|
69
- result[key.to_s] = value.is_a?(Array) ? value.join(', ') : value.to_s
70
- end
71
- end
72
-
73
- def self.hash_at(value, key)
74
- child = value[key] if value.is_a?(Hash)
75
- child.is_a?(Hash) ? child : nil
76
- end
77
-
78
- def self.string_at(value, key)
79
- child = value[key] if value.is_a?(Hash)
80
- child.is_a?(String) && !child.empty? ? child : nil
81
- end
82
-
83
- def self.bool_at(value, key)
84
- child = value[key] if value.is_a?(Hash)
85
- [true, false].include?(child) ? child : nil
86
- end
87
-
88
- def self.retryable(detail, status)
89
- explicit = bool_at(detail, 'retryable')
90
- explicit.nil? ? default_retryable?(status) : explicit
91
- end
92
-
93
- def self.header(headers, name)
94
- pair = headers.find { |key, _value| key.downcase == name }
95
- pair&.last
96
- end
97
-
98
- def self.default_retryable?(status)
99
- status == 429 || (status.is_a?(Integer) && status >= 500)
100
- end
101
- end
102
- end
103
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Sendmux
4
- module Core
5
- module Headers
6
- def self.idempotency_key(value)
7
- { idempotency_key: value }
8
- end
9
-
10
- def self.if_match(value)
11
- { if_match: value }
12
- end
13
-
14
- def self.if_none_match(value)
15
- { if_none_match: value }
16
- end
17
-
18
- def self.conditional(if_match: nil, if_none_match: nil)
19
- {}.tap do |headers|
20
- headers[:if_match] = if_match if if_match
21
- headers[:if_none_match] = if_none_match if if_none_match
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,64 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Sendmux
4
- module Core
5
- class CursorPager
6
- include Enumerable
7
-
8
- def initialize(fetch_page, cursor_param: :cursor)
9
- @fetch_page = fetch_page
10
- @cursor_param = cursor_param
11
- end
12
-
13
- def each(&block)
14
- return enum_for(:each) unless block_given?
15
-
16
- cursor = nil
17
- loop do
18
- response = @fetch_page.call(cursor ? { @cursor_param => cursor } : {})
19
- extract_items(response).each(&block)
20
- pagination = extract_pagination(response)
21
- break unless bool_value?(pagination, 'has_more')
22
-
23
- cursor = value(pagination, 'next_cursor')
24
- break unless cursor
25
- end
26
- end
27
-
28
- private
29
-
30
- def extract_items(response)
31
- data = value(response, 'data')
32
- return data if data.is_a?(Array)
33
-
34
- []
35
- end
36
-
37
- def extract_pagination(response)
38
- meta = value(response, 'meta')
39
- value(meta, 'pagination') || value(response, 'pagination') || {}
40
- end
41
-
42
- def bool_value?(object, name)
43
- value(object, name) == true
44
- end
45
-
46
- def value(object, name)
47
- return object[name] || object[name.to_sym] if object.is_a?(Hash)
48
- return object.public_send(name) if object.respond_to?(name)
49
-
50
- method = snake_to_camel(name)
51
- object.public_send(method) if object.respond_to?(method)
52
- end
53
-
54
- def snake_to_camel(name)
55
- parts = name.to_s.split('_')
56
- parts.first + parts.drop(1).map(&:capitalize).join
57
- end
58
- end
59
-
60
- def self.each_cursor(fetch_page, cursor_param: :cursor)
61
- CursorPager.new(fetch_page, cursor_param: cursor_param)
62
- end
63
- end
64
- end
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'faraday/retry'
4
-
5
- module Sendmux
6
- module Core
7
- module Retry
8
- SAFE_METHODS = %w[GET HEAD OPTIONS].freeze
9
-
10
- def self.configure(configuration, retry_options = nil)
11
- options = retry_options || RetryOptions.new
12
- configuration.request(:retry, options.to_faraday_options)
13
- end
14
-
15
- def self.retryable_request?(env)
16
- return false if explicitly_non_retryable?(env[:body])
17
-
18
- method = env[:method].to_s.upcase
19
- return true if SAFE_METHODS.include?(method)
20
-
21
- method == 'POST' && header(env[:request_headers] || {}, 'Idempotency-Key') && replayable_body?(env[:body])
22
- end
23
-
24
- def self.explicitly_non_retryable?(body)
25
- payload = ErrorMapper.payload_from(body)
26
- detail = ErrorMapper.hash_at(payload, 'error')
27
- payload.is_a?(Hash) && payload['ok'] == false && detail && detail['retryable'] == false
28
- end
29
-
30
- def self.header(headers, name)
31
- headers.find { |key, _value| key.to_s.downcase == name.downcase }&.last
32
- end
33
-
34
- def self.replayable_body?(body)
35
- body.nil? || body.is_a?(String) || body.respond_to?(:rewind)
36
- end
37
- end
38
- end
39
- end
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Sendmux
4
- module Core
5
- class RetryOptions
6
- RETRY_STATUSES = [408, 409, 425, 429, 500, 502, 503, 504].freeze
7
-
8
- attr_reader :max_attempts, :base_delay_seconds, :max_delay_seconds, :jitter
9
-
10
- def initialize(max_attempts: 3, base_delay_seconds: 0.25, max_delay_seconds: 5.0, jitter: true)
11
- raise ArgumentError, 'max_attempts must be at least 1' if max_attempts < 1
12
- if base_delay_seconds.negative? || max_delay_seconds.negative?
13
- raise ArgumentError,
14
- 'retry delays must be non-negative'
15
- end
16
-
17
- @max_attempts = max_attempts
18
- @base_delay_seconds = base_delay_seconds
19
- @max_delay_seconds = max_delay_seconds
20
- @jitter = jitter
21
- end
22
-
23
- def to_faraday_options
24
- {
25
- max: max_attempts - 1,
26
- interval: base_delay_seconds,
27
- max_interval: max_delay_seconds,
28
- interval_randomness: jitter ? 0.5 : 0.0,
29
- backoff_factor: 2,
30
- methods: [],
31
- retry_statuses: RETRY_STATUSES,
32
- rate_limit_retry_header: 'Retry-After',
33
- rate_limit_reset_header: 'X-RateLimit-Reset',
34
- retry_if: ->(env, _exception) { Retry.retryable_request?(env) }
35
- }
36
- end
37
- end
38
- end
39
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Sendmux
4
- module Core
5
- VERSION = '1.3.0'
6
- end
7
- end
data/lib/sendmux/core.rb DELETED
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'sendmux/core/api_key_surface'
4
- require 'sendmux/core/auth'
5
- require 'sendmux/core/errors'
6
- require 'sendmux/core/headers'
7
- require 'sendmux/core/pagination'
8
- require 'sendmux/core/retry'
9
- require 'sendmux/core/retry_options'
10
- require 'sendmux/core/version'