hearth 1.0.0.pre1 → 1.0.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -4
  3. data/VERSION +1 -1
  4. data/lib/hearth/api_error.rb +15 -1
  5. data/lib/hearth/auth_option.rb +21 -0
  6. data/lib/hearth/auth_schemes/anonymous.rb +21 -0
  7. data/lib/hearth/auth_schemes/http_api_key.rb +16 -0
  8. data/lib/hearth/auth_schemes/http_basic.rb +16 -0
  9. data/lib/hearth/auth_schemes/http_bearer.rb +16 -0
  10. data/lib/hearth/auth_schemes/http_digest.rb +16 -0
  11. data/lib/hearth/auth_schemes.rb +32 -0
  12. data/lib/hearth/checksums.rb +31 -0
  13. data/lib/hearth/client_stubs.rb +130 -0
  14. data/lib/hearth/config/env_provider.rb +53 -0
  15. data/lib/hearth/config/resolver.rb +52 -0
  16. data/lib/hearth/configuration.rb +15 -0
  17. data/lib/hearth/connection_pool.rb +77 -0
  18. data/lib/hearth/context.rb +28 -4
  19. data/lib/hearth/dns/host_address.rb +23 -0
  20. data/lib/hearth/dns/host_resolver.rb +92 -0
  21. data/lib/hearth/dns.rb +48 -0
  22. data/lib/hearth/http/api_error.rb +4 -8
  23. data/lib/hearth/http/client.rb +208 -59
  24. data/lib/hearth/http/error_inspector.rb +85 -0
  25. data/lib/hearth/http/error_parser.rb +18 -20
  26. data/lib/hearth/http/field.rb +64 -0
  27. data/lib/hearth/http/fields.rb +117 -0
  28. data/lib/hearth/http/middleware/content_length.rb +5 -2
  29. data/lib/hearth/http/middleware/content_md5.rb +31 -0
  30. data/lib/hearth/http/middleware/request_compression.rb +157 -0
  31. data/lib/hearth/http/middleware.rb +12 -0
  32. data/lib/hearth/http/networking_error.rb +1 -14
  33. data/lib/hearth/http/request.rb +83 -56
  34. data/lib/hearth/http/response.rb +42 -13
  35. data/lib/hearth/http.rb +14 -5
  36. data/lib/hearth/identities/anonymous.rb +8 -0
  37. data/lib/hearth/identities/http_api_key.rb +16 -0
  38. data/lib/hearth/identities/http_bearer.rb +16 -0
  39. data/lib/hearth/identities/http_login.rb +20 -0
  40. data/lib/hearth/identities.rb +21 -0
  41. data/lib/hearth/identity_resolver.rb +17 -0
  42. data/lib/hearth/interceptor.rb +506 -0
  43. data/lib/hearth/interceptor_context.rb +36 -0
  44. data/lib/hearth/interceptor_list.rb +48 -0
  45. data/lib/hearth/interceptors.rb +75 -0
  46. data/lib/hearth/middleware/auth.rb +100 -0
  47. data/lib/hearth/middleware/build.rb +32 -0
  48. data/lib/hearth/middleware/host_prefix.rb +10 -6
  49. data/lib/hearth/middleware/initialize.rb +58 -0
  50. data/lib/hearth/middleware/parse.rb +45 -6
  51. data/lib/hearth/middleware/retry.rb +97 -23
  52. data/lib/hearth/middleware/send.rb +137 -25
  53. data/lib/hearth/middleware/sign.rb +65 -0
  54. data/lib/hearth/middleware/validate.rb +11 -1
  55. data/lib/hearth/middleware.rb +19 -8
  56. data/lib/hearth/middleware_stack.rb +1 -43
  57. data/lib/hearth/networking_error.rb +18 -0
  58. data/lib/hearth/number_helper.rb +2 -2
  59. data/lib/hearth/output.rb +8 -4
  60. data/lib/hearth/plugin_list.rb +53 -0
  61. data/lib/hearth/query/param.rb +52 -0
  62. data/lib/hearth/query/param_list.rb +54 -0
  63. data/lib/hearth/query/param_matcher.rb +32 -0
  64. data/lib/hearth/refreshing_identity_resolver.rb +63 -0
  65. data/lib/hearth/request.rb +22 -0
  66. data/lib/hearth/response.rb +33 -0
  67. data/lib/hearth/retry/adaptive.rb +60 -0
  68. data/lib/hearth/retry/capacity_not_available_error.rb +9 -0
  69. data/lib/hearth/retry/client_rate_limiter.rb +143 -0
  70. data/lib/hearth/retry/exponential_backoff.rb +15 -0
  71. data/lib/hearth/retry/retry_quota.rb +56 -0
  72. data/lib/hearth/retry/standard.rb +46 -0
  73. data/lib/hearth/retry/strategy.rb +20 -0
  74. data/lib/hearth/retry.rb +16 -0
  75. data/lib/hearth/signers/anonymous.rb +16 -0
  76. data/lib/hearth/signers/http_api_key.rb +29 -0
  77. data/lib/hearth/signers/http_basic.rb +23 -0
  78. data/lib/hearth/signers/http_bearer.rb +19 -0
  79. data/lib/hearth/signers/http_digest.rb +19 -0
  80. data/lib/hearth/signers.rb +23 -0
  81. data/lib/hearth/stubs.rb +30 -0
  82. data/lib/hearth/time_helper.rb +5 -3
  83. data/lib/hearth/validator.rb +44 -5
  84. data/lib/hearth/waiters/poller.rb +6 -7
  85. data/lib/hearth/waiters/waiter.rb +17 -4
  86. data/lib/hearth/xml/formatter.rb +11 -2
  87. data/lib/hearth/xml/node.rb +2 -2
  88. data/lib/hearth.rb +32 -5
  89. data/sig/lib/hearth/aliases.rbs +4 -0
  90. data/sig/lib/hearth/api_error.rbs +13 -0
  91. data/sig/lib/hearth/auth_option.rbs +11 -0
  92. data/sig/lib/hearth/auth_schemes/anonymous.rbs +7 -0
  93. data/sig/lib/hearth/auth_schemes/http_api_key.rbs +7 -0
  94. data/sig/lib/hearth/auth_schemes/http_basic.rbs +7 -0
  95. data/sig/lib/hearth/auth_schemes/http_bearer.rbs +7 -0
  96. data/sig/lib/hearth/auth_schemes/http_digest.rbs +7 -0
  97. data/sig/lib/hearth/auth_schemes.rbs +13 -0
  98. data/sig/lib/hearth/block_io.rbs +9 -0
  99. data/sig/lib/hearth/client_stubs.rbs +5 -0
  100. data/sig/lib/hearth/configuration.rbs +7 -0
  101. data/sig/lib/hearth/dns/host_address.rbs +13 -0
  102. data/sig/lib/hearth/dns/host_resolver.rbs +19 -0
  103. data/sig/lib/hearth/http/api_error.rbs +13 -0
  104. data/sig/lib/hearth/http/client.rbs +9 -0
  105. data/sig/lib/hearth/http/field.rbs +19 -0
  106. data/sig/lib/hearth/http/fields.rbs +43 -0
  107. data/sig/lib/hearth/http/request.rbs +25 -0
  108. data/sig/lib/hearth/http/response.rbs +21 -0
  109. data/sig/lib/hearth/identities/anonymous.rbs +6 -0
  110. data/sig/lib/hearth/identities/http_api_key.rbs +9 -0
  111. data/sig/lib/hearth/identities/http_bearer.rbs +9 -0
  112. data/sig/lib/hearth/identities/http_login.rbs +11 -0
  113. data/sig/lib/hearth/identities.rbs +9 -0
  114. data/sig/lib/hearth/identity_resolver.rbs +7 -0
  115. data/sig/lib/hearth/interceptor.rbs +9 -0
  116. data/sig/lib/hearth/interceptor_context.rbs +15 -0
  117. data/sig/lib/hearth/interceptor_list.rbs +16 -0
  118. data/sig/lib/hearth/interfaces.rbs +65 -0
  119. data/sig/lib/hearth/output.rbs +11 -0
  120. data/sig/lib/hearth/plugin_list.rbs +15 -0
  121. data/sig/lib/hearth/query/param.rbs +17 -0
  122. data/sig/lib/hearth/query/param_list.rbs +25 -0
  123. data/sig/lib/hearth/request.rbs +9 -0
  124. data/sig/lib/hearth/response.rbs +11 -0
  125. data/sig/lib/hearth/retry/adaptive.rbs +13 -0
  126. data/sig/lib/hearth/retry/exponential_backoff.rbs +7 -0
  127. data/sig/lib/hearth/retry/standard.rbs +13 -0
  128. data/sig/lib/hearth/retry/strategy.rbs +11 -0
  129. data/sig/lib/hearth/retry.rbs +9 -0
  130. data/sig/lib/hearth/signers/anonymous.rbs +9 -0
  131. data/sig/lib/hearth/signers/http_api_key.rbs +9 -0
  132. data/sig/lib/hearth/signers/http_basic.rbs +9 -0
  133. data/sig/lib/hearth/signers/http_bearer.rbs +9 -0
  134. data/sig/lib/hearth/signers/http_digest.rbs +9 -0
  135. data/sig/lib/hearth/signers.rbs +9 -0
  136. data/sig/lib/hearth/structure.rbs +7 -0
  137. data/sig/lib/hearth/union.rbs +5 -0
  138. data/sig/lib/hearth/waiters/waiter.rbs +17 -0
  139. metadata +132 -22
  140. data/lib/hearth/http/headers.rb +0 -70
  141. data/lib/hearth/middleware/around_handler.rb +0 -24
  142. data/lib/hearth/middleware/request_handler.rb +0 -24
  143. data/lib/hearth/middleware/response_handler.rb +0 -25
  144. data/lib/hearth/middleware_builder.rb +0 -246
  145. data/lib/hearth/stubbing/client_stubs.rb +0 -115
  146. data/lib/hearth/stubbing/stubs.rb +0 -32
  147. data/lib/hearth/waiters/errors.rb +0 -15
  148. data/sig/lib/seahorse/api_error.rbs +0 -10
  149. data/sig/lib/seahorse/document.rbs +0 -2
  150. data/sig/lib/seahorse/http/api_error.rbs +0 -21
  151. data/sig/lib/seahorse/http/headers.rbs +0 -47
  152. data/sig/lib/seahorse/http/response.rbs +0 -21
  153. data/sig/lib/seahorse/simple_delegator.rbs +0 -3
  154. data/sig/lib/seahorse/structure.rbs +0 -18
  155. data/sig/lib/seahorse/stubbing/client_stubs.rbs +0 -103
  156. data/sig/lib/seahorse/stubbing/stubs.rbs +0 -14
  157. data/sig/lib/seahorse/union.rbs +0 -6
data/lib/hearth.rb CHANGED
@@ -1,22 +1,49 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'hearth/api_error'
4
+ require_relative 'hearth/auth_option'
5
+
6
+ # must be required before auth_schemes
7
+ require_relative 'hearth/identities'
8
+ require_relative 'hearth/auth_schemes'
9
+
4
10
  require_relative 'hearth/block_io'
11
+ require_relative 'hearth/checksums'
12
+ require_relative 'hearth/client_stubs'
13
+ require_relative 'hearth/configuration'
14
+ require_relative 'hearth/config/env_provider'
15
+ require_relative 'hearth/config/resolver'
16
+ require_relative 'hearth/connection_pool'
5
17
  require_relative 'hearth/context'
18
+ require_relative 'hearth/dns'
19
+
20
+ # must be required before http
21
+ require_relative 'hearth/middleware'
22
+ require_relative 'hearth/networking_error'
23
+ require_relative 'hearth/request'
24
+ require_relative 'hearth/response'
25
+
6
26
  require_relative 'hearth/http'
27
+ require_relative 'hearth/identity_resolver'
28
+ require_relative 'hearth/interceptor'
29
+ require_relative 'hearth/interceptors'
30
+ require_relative 'hearth/interceptor_context'
31
+ require_relative 'hearth/interceptor_list'
7
32
  require_relative 'hearth/json'
8
- require_relative 'hearth/middleware'
9
- require_relative 'hearth/middleware_builder'
33
+ require_relative 'hearth/plugin_list'
10
34
  require_relative 'hearth/middleware_stack'
11
35
  require_relative 'hearth/number_helper'
12
36
  require_relative 'hearth/output'
37
+ require_relative 'hearth/query/param'
38
+ require_relative 'hearth/query/param_list'
39
+ require_relative 'hearth/refreshing_identity_resolver'
40
+ require_relative 'hearth/retry'
41
+ require_relative 'hearth/signers'
13
42
  require_relative 'hearth/structure'
14
- require_relative 'hearth/stubbing/client_stubs'
15
- require_relative 'hearth/stubbing/stubs'
43
+ require_relative 'hearth/stubs'
16
44
  require_relative 'hearth/time_helper'
17
45
  require_relative 'hearth/union'
18
46
  require_relative 'hearth/validator'
19
- require_relative 'hearth/waiters/errors'
20
47
  require_relative 'hearth/waiters/poller'
21
48
  require_relative 'hearth/waiters/waiter'
22
49
  require_relative 'hearth/xml'
@@ -0,0 +1,4 @@
1
+ type document = Hash[Symbol,document] | Array[document] | String | bool | Numeric
2
+
3
+ type stub = Hearth::Structure | Hearth::Response | { data: Hash[Symbol, untyped] } |
4
+ { error: { class: Class, data: Hash[Symbol, untyped] } } | Hearth::ApiError | Proc
@@ -0,0 +1,13 @@
1
+ module Hearth
2
+ class ApiError < StandardError
3
+ def initialize: (error_code: String, ?metadata: Hash[Symbol, untyped], ?message: String?) -> void
4
+
5
+ attr_reader error_code: String
6
+
7
+ attr_reader metadata: Hash[Symbol, untyped]
8
+
9
+ def retryable?: () -> false
10
+
11
+ def throttling?: () -> false
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ module Hearth
2
+ class AuthOption
3
+ def initialize: (scheme_id: String, ?identity_properties: Hash[Symbol, untyped], ?signer_properties: Hash[Symbol, untyped]) -> void
4
+
5
+ attr_reader scheme_id: String
6
+
7
+ attr_reader identity_properties: Hash[Symbol, untyped]
8
+
9
+ attr_reader signer_properties: Hash[Symbol, untyped]
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ module Hearth
2
+ module AuthSchemes
3
+ class Anonymous < AuthSchemes::Base
4
+ def initialize: () -> void
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Hearth
2
+ module AuthSchemes
3
+ class HTTPApiKey < AuthSchemes::Base
4
+ def initialize: () -> void
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Hearth
2
+ module AuthSchemes
3
+ class HTTPBasic < AuthSchemes::Base
4
+ def initialize: () -> void
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Hearth
2
+ module AuthSchemes
3
+ class HTTPBearer < AuthSchemes::Base
4
+ def initialize: () -> void
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Hearth
2
+ module AuthSchemes
3
+ class HTTPDigest < AuthSchemes::Base
4
+ def initialize: () -> void
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,13 @@
1
+ module Hearth
2
+ module AuthSchemes
3
+ class Base
4
+ def initialize: (scheme_id: String, signer: Signers::Base, identity_type: Class) -> void
5
+
6
+ attr_reader scheme_id: String
7
+
8
+ def identity_resolver: (?Hash[Symbol, IdentityResolver] identity_resolvers) -> IdentityResolver
9
+
10
+ attr_reader signer: Signers::Base
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ module Hearth
2
+ class BlockIO
3
+ def initialize: (Proc block) -> void
4
+
5
+ attr_reader bytes_yielded: Integer
6
+
7
+ def write: (String data) -> Integer
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module Hearth
2
+ module ClientStubs
3
+ def stub_responses: (Symbol operation_name, *stub stubs) -> void
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ module Hearth
2
+ module Configuration
3
+ def initialize: (**Hash[Symbol, untyped] options) -> void
4
+
5
+ def dup: () -> Hearth::Configuration
6
+ end
7
+ end
@@ -0,0 +1,13 @@
1
+ module Hearth
2
+ module DNS
3
+ class HostAddress
4
+ def initialize: (address_type: Symbol, address: String, hostname: String) -> void
5
+
6
+ attr_reader address_type: Symbol
7
+
8
+ attr_reader address: String
9
+
10
+ attr_reader hostname: String
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,19 @@
1
+ module Hearth
2
+ module DNS
3
+ class HostResolver
4
+ def initialize: (?service: Integer, ?family: Integer?, ?socktype: Symbol, ?protocol: Integer?, ?flags: Integer?) -> void
5
+
6
+ attr_reader service: Integer
7
+
8
+ attr_reader family: Integer
9
+
10
+ attr_reader socktype: Symbol
11
+
12
+ attr_reader protocol: Integer
13
+
14
+ attr_reader flags: Integer
15
+
16
+ def resolve_address: (nodename: String, ?service: Integer, ?family: Integer?, ?socktype: Symbol, ?protocol: Integer?, ?flags: Integer?) -> Array[HostAddress]
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,13 @@
1
+ module Hearth
2
+ module HTTP
3
+ class ApiError < Hearth::ApiError
4
+ def initialize: (http_resp: Response, error_code: String, ?metadata: Hash[Symbol, untyped], ?message: String?) -> void
5
+
6
+ attr_reader http_status: Integer
7
+
8
+ attr_reader http_fields: Fields
9
+
10
+ attr_reader http_body: IO
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ module Hearth
2
+ module HTTP
3
+ class Client
4
+ def initialize: (?::Hash[Symbol, untyped] options) -> void
5
+
6
+ def transmit: (request: HTTP::Request, response: HTTP::Response, ?logger: Logger?) -> void
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ module Hearth
2
+ module HTTP
3
+ class Field
4
+ def initialize: (String name, ?(Array[String] | _ToS)? value, ?kind: Symbol) -> void
5
+
6
+ attr_reader name: String
7
+
8
+ attr_reader kind: Symbol
9
+
10
+ def value: (?String? encoding) -> String
11
+
12
+ def header?: () -> bool
13
+
14
+ def trailer?: () -> bool
15
+
16
+ def to_h: () -> Hash[String, String]
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,43 @@
1
+ module Hearth
2
+ module HTTP
3
+ class Fields
4
+ include Enumerable[Field]
5
+
6
+ def initialize: (?Array[Field] fields, ?encoding: String) -> void
7
+
8
+ attr_reader encoding: String
9
+
10
+ def []: (String key) -> Field
11
+
12
+ def []=: (String key, Field value) -> Field
13
+
14
+ def key?: (String key) -> bool
15
+
16
+ def delete: (String key) -> (Field | nil)
17
+
18
+ def each: () { (Field) -> void } -> void
19
+
20
+ def size: () -> Integer
21
+
22
+ def clear: () -> void
23
+
24
+ class Proxy
25
+ include Enumerable[Hash[String, String]]
26
+
27
+ def initialize: (Array[Field] fields, Symbol kind) -> void
28
+
29
+ def []: (String key) -> (String | nil)
30
+
31
+ def []=: (String, String) -> String
32
+
33
+ def key?: (String) -> bool
34
+
35
+ def delete: (String key) -> (String | nil)
36
+
37
+ def each: () { (Hash[String, String]) -> void } -> void
38
+
39
+ alias each_pair each
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,25 @@
1
+ module Hearth
2
+ module HTTP
3
+ class Request < Hearth::Request
4
+ def initialize: (?http_method: Symbol?, ?fields: Fields, ?uri: URI, ?body: IO) -> void
5
+
6
+ attr_accessor http_method: Symbol
7
+
8
+ attr_reader fields: Fields
9
+
10
+ attr_reader headers: Fields::Proxy
11
+
12
+ attr_reader trailers: Fields::Proxy
13
+
14
+ def append_path: (String path) -> void
15
+
16
+ def append_query_param: (String name, String? value) -> void
17
+
18
+ def append_query_param_list: (Query::ParamList param_list) -> void
19
+
20
+ def remove_query_param: (String name) -> void
21
+
22
+ def prefix_host: (String prefix) -> void
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,21 @@
1
+ module Hearth
2
+ module HTTP
3
+ class Response < Hearth::Response
4
+ def initialize: (?status: Integer, ?reason: String?, ?fields: Fields, ?body: IO) -> void
5
+
6
+ attr_accessor status: Integer
7
+
8
+ attr_accessor reason: (String | nil)
9
+
10
+ attr_reader fields: Fields
11
+
12
+ attr_reader headers: Fields::Proxy
13
+
14
+ attr_reader trailers: Fields::Proxy
15
+
16
+ def replace: (Response other) -> self
17
+
18
+ def reset: () -> void
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,6 @@
1
+ module Hearth
2
+ module Identities
3
+ class Anonymous < Identities::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,9 @@
1
+ module Hearth
2
+ module Identities
3
+ class HTTPApiKey < Identities::Base
4
+ def initialize: (key: String, ?expiration: Time?) -> void
5
+
6
+ attr_reader key: String
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Hearth
2
+ module Identities
3
+ class HTTPBearer < Identities::Base
4
+ def initialize: (token: String, ?expiration: Time?) -> void
5
+
6
+ attr_reader token: String
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ module Hearth
2
+ module Identities
3
+ class HTTPLogin < Identities::Base
4
+ def initialize: (username: String, password: String, ?expiration: Time?) -> void
5
+
6
+ attr_reader username: String
7
+
8
+ attr_reader password: String
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ module Hearth
2
+ module Identities
3
+ class Base
4
+ def initialize: (?expiration: Time?) -> void
5
+
6
+ attr_reader expiration: Time
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ module Hearth
2
+ class IdentityResolver
3
+ def initialize: (Proc) -> void
4
+
5
+ def identity: (?Hash[Symbol, untyped] properties) -> Identities::Base
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ module Hearth
2
+ class Interceptor
3
+ def initialize: (?Hash[Symbol, Proc] callbacks) -> void
4
+
5
+ attr_reader callbacks: Hash[Symbol, Proc]
6
+
7
+ attr_reader self.hooks: Array[Symbol]
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ module Hearth
2
+ class InterceptorContext
3
+ def initialize: (input: Structure, request: Request, response: Response, output: Structure, ?attributes: Hash[Symbol, untyped]) -> void
4
+
5
+ attr_reader input: Structure
6
+
7
+ attr_reader request: Request
8
+
9
+ attr_reader response: Response
10
+
11
+ attr_reader output: Structure
12
+
13
+ attr_reader attributes: Hash[Symbol, untyped]
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ module Hearth
2
+ class InterceptorList
3
+ include Enumerable[_Interceptor]
4
+
5
+ def initialize: (?Array[_Interceptor] interceptors) -> void
6
+
7
+ def append: (_Interceptor interceptor) -> void
8
+ alias << append
9
+
10
+ def concat: (InterceptorList other) -> self
11
+
12
+ def dup: () -> InterceptorList
13
+
14
+ def each: () { (_Interceptor) -> untyped } -> untyped
15
+ end
16
+ end
@@ -0,0 +1,65 @@
1
+ # Hack - https://github.com/ruby/delegate/issues/8
2
+ class SimpleDelegator
3
+ end
4
+
5
+ # Hack - https://github.com/ruby/rbs/issues/1481
6
+ class URI
7
+ end
8
+
9
+ # Hack - https://github.com/ruby/rbs/issues/1482
10
+ class Logger
11
+ end
12
+
13
+ interface _Plugin
14
+ def call: (Hearth::Configuration) -> void
15
+ end
16
+
17
+ interface _Interceptor
18
+ def read_before_execution: (Hearth::InterceptorContext) -> void
19
+
20
+ def modify_before_serialization: (Hearth::InterceptorContext) -> void
21
+
22
+ def read_before_serialization: (Hearth::InterceptorContext) -> void
23
+
24
+ def read_after_serialization: (Hearth::InterceptorContext) -> void
25
+
26
+ def modify_before_retry_loop: (Hearth::InterceptorContext) -> void
27
+
28
+ def read_before_attempt: (Hearth::InterceptorContext) -> void
29
+
30
+ def modify_before_signing: (Hearth::InterceptorContext) -> void
31
+
32
+ def read_before_signing: (Hearth::InterceptorContext) -> void
33
+
34
+ def read_after_signing: (Hearth::InterceptorContext) -> void
35
+
36
+ def modify_before_transmit: (Hearth::InterceptorContext) -> void
37
+
38
+ def read_before_transmit: (Hearth::InterceptorContext) -> void
39
+
40
+ def read_after_transmit: (Hearth::InterceptorContext) -> void
41
+
42
+ def modify_before_deserialization: (Hearth::InterceptorContext) -> void
43
+
44
+ def read_before_deserialization: (Hearth::InterceptorContext) -> void
45
+
46
+ def read_after_deserialization: (Hearth::InterceptorContext) -> void
47
+
48
+ def modify_before_attempt_completion: (Hearth::InterceptorContext) -> void
49
+
50
+ def read_after_attempt: (Hearth::InterceptorContext) -> void
51
+
52
+ def modify_before_completion: (Hearth::InterceptorContext) -> void
53
+
54
+ def read_after_execution: (Hearth::InterceptorContext) -> void
55
+ end
56
+
57
+ interface _ErrorInspector
58
+ def initialize: (Hearth::ApiError, Hearth::Response) -> void
59
+
60
+ def retryable?: () -> bool
61
+
62
+ def error_type: () -> String
63
+
64
+ def hints: () -> Hash[Symbol, untyped]
65
+ end
@@ -0,0 +1,11 @@
1
+ module Hearth
2
+ class Output
3
+ def initialize: (?error: (ApiError)?, ?data: (Structure)?, ?metadata: Hash[Symbol, untyped]) -> void
4
+
5
+ attr_accessor error: (ApiError | nil)
6
+
7
+ attr_accessor data: (Structure | nil)
8
+
9
+ attr_accessor metadata: Hash[Symbol, untyped]
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ module Hearth
2
+ class PluginList
3
+ def initialize: (?Array[_Plugin] plugins) -> void
4
+
5
+ def add: (_Plugin plugin) -> void
6
+
7
+ alias << add
8
+
9
+ def apply: (Hearth::Configuration) -> void
10
+
11
+ def dup: () -> PluginList
12
+
13
+ def each: () ?{ (_Plugin) -> void } -> void
14
+ end
15
+ end
@@ -0,0 +1,17 @@
1
+ module Hearth
2
+ module Query
3
+ class Param
4
+ def initialize: (String name, ?(String | Array[String])? value) -> void
5
+
6
+ attr_reader name: String
7
+
8
+ attr_reader value: (String | Array[String])
9
+
10
+ def to_s: () -> String
11
+
12
+ def ==: (Param other) -> bool
13
+
14
+ def <=>: (Param other) -> bool
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,25 @@
1
+ module Hearth
2
+ module Query
3
+ class ParamList
4
+ include Enumerable[String]
5
+
6
+ def initialize: () -> void
7
+
8
+ def set: (String param_name, ?String? param_value) -> Param
9
+
10
+ alias []= set
11
+
12
+ def []: (Param param_name) -> (Param | nil)
13
+
14
+ def delete: (Param param_name) -> (Param | nil)
15
+
16
+ def each: () { (String) -> void } -> void
17
+
18
+ def empty?: () -> bool
19
+
20
+ def to_a: () -> Array[Param]
21
+
22
+ def to_s: () -> String
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,9 @@
1
+ module Hearth
2
+ class Request
3
+ def initialize: (?uri: URI, ?body: IO) -> void
4
+
5
+ attr_accessor uri: URI
6
+
7
+ attr_accessor body: IO
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ module Hearth
2
+ class Response
3
+ def initialize: (?body: IO) -> void
4
+
5
+ attr_accessor body: IO
6
+
7
+ def replace: (Response other) -> self
8
+
9
+ def reset: () -> self
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ module Hearth
2
+ module Retry
3
+ class Adaptive < Strategy
4
+ def initialize: (?backoff: ExponentialBackoff, ?max_attempts: Integer, ?wait_to_fill: bool) -> void
5
+
6
+ def acquire_initial_retry_token: (?String? _token_scope) -> Token
7
+
8
+ def refresh_retry_token: (Token retry_token, _ErrorInspector error_info) -> (nil | Token)
9
+
10
+ def record_success: (Token retry_token) -> Token
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ module Hearth
2
+ module Retry
3
+ class ExponentialBackoff
4
+ def call: (Integer attempts) -> Float
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,13 @@
1
+ module Hearth
2
+ module Retry
3
+ class Standard < Strategy
4
+ def initialize: (?backoff: ExponentialBackoff, ?max_attempts: Integer) -> void
5
+
6
+ def acquire_initial_retry_token: (?String? _token_scope) -> Token
7
+
8
+ def refresh_retry_token: (Token retry_token, _ErrorInspector error_info) -> (nil | Token)
9
+
10
+ def record_success: (Token retry_token) -> Token
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ module Hearth
2
+ module Retry
3
+ class Strategy
4
+ def acquire_initial_retry_token: (?String? _token_scope) -> Token
5
+
6
+ def refresh_retry_token: (Token _retry_token, _ErrorInspector _error_info) -> (nil | Token)
7
+
8
+ def record_success: (Token _retry_token) -> Token
9
+ end
10
+ end
11
+ end