sorbet_typed-short_circuit 0.1.0 → 1.0.1

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: 7eac217ecd0ee520431efe864e122dfd5e27ea426e3041d57ef5d4ad17f735f3
4
- data.tar.gz: 64c245c6e20806c1b8856d2cd071c49752d41ed88ae09b4652b3fc7581f44f83
3
+ metadata.gz: '08803ee36dcd1a14fa795cba7cf0255b5b74072fb859b87dce05393560da3fd4'
4
+ data.tar.gz: 7124bb0a3037c5396c7f81c7e8f3bc0bdfc406ca51f905830c9b38882aaedba1
5
5
  SHA512:
6
- metadata.gz: 54d29ca68e65bfb32d511d0f8f3cc17ec29ae45db1f575ef3e00c71ddcce3458186560605d6639c3f1c799001327ebb1ae14fdad5fddefb9e38b06431fcd91da
7
- data.tar.gz: '0049e24a52c6bbbb8909aaf382408eb187c0824858dca534e6886a8652c59bb128c3cfc792d33cff1d34526c0d4d3b25cf4baa7189918ba50bc2d139f10068f3'
6
+ metadata.gz: d7ac4e8ecf662553299bf77ff0cfe41377daf800eeded929405a11f38afd9e85fa1d2adf4ae784f49ea7f2a74af6697f7f6a069d3751468b5f7c9b5e088b4017
7
+ data.tar.gz: 91f6361decd575b09d593c61076316a0256a7b0a828cd848c48cba101ec5516f9a7f9094af09d5f97d5eaf1b76e13c85d433e20d3ebc85a7c6ff36ecf3735932
data/.cz.yaml ADDED
@@ -0,0 +1,20 @@
1
+ ---
2
+ commitizen:
3
+ allowed_prefixes:
4
+ - fixup!
5
+ - squash!
6
+ - Merge
7
+ - Revert
8
+ - '[WIP]'
9
+ annotated_tag: true
10
+ name: cz_conventional_commits
11
+ pre_bump_hooks:
12
+ - mise x -- bundle install
13
+ - mise run update
14
+ - mise run format
15
+ tag_format: v$version
16
+ update_changelog_on_bump: true
17
+ version: 1.0.1
18
+ version_files:
19
+ - lib/sorbet_typed/short_circuit/version.rb
20
+ version_scheme: semver2
@@ -0,0 +1,8 @@
1
+ repos:
2
+ - hooks:
3
+ - id: commitizen
4
+ - id: commitizen-branch
5
+ stages:
6
+ - pre-push
7
+ repo: https://github.com/commitizen-tools/commitizen
8
+ rev: v4.9.1
data/CHANGELOG.md ADDED
@@ -0,0 +1,39 @@
1
+ ## v1.0.1 (2025-11-10)
2
+
3
+ ### Fix
4
+
5
+ - **dependencies**: Update ruby docker image digests
6
+ - **dependencies**: Lock file maintenance
7
+ - **dependencies**: Update dependency pre-commit to v4.4.0
8
+ - **dependencies**: Update bun to v1.3.2
9
+ - **dependencies**: Update dependency jdx/mise to v2025.11.3
10
+ - **dependencies**: Update dependency uv to v0.9.8
11
+ - **dependencies**: Update ruby:3.4.7 Docker digest to c8c6b15
12
+
13
+ ## v1.0.0 (2025-11-07)
14
+
15
+ ### Feat
16
+
17
+ - **CircuitBreaker**: allow public usage in signatures
18
+ - **interface**: add specs and update interfaces
19
+ - **renovate**: update CI matrix on lockFileMaintenance
20
+ - **ci**: trigger renovate pipeline on default branch
21
+ - **mise**: change default task output to "replacing"
22
+ - **mise**: execute typecheck when running lint task
23
+ - **renovate**: remove manual usage dependency declaration, as renovate seems to know it now
24
+ - initial commit
25
+
26
+ ### Fix
27
+
28
+ - **ci**: adjust job rules
29
+ - **sorbet**: robust tapioca dsl update/verification + removal of unused DSL RBIs
30
+ - **sorbet**: exclude local gem from RBI generation
31
+ - **renovate**: group ci ruby version matrix upgrades
32
+ - **ci**: run ruby version matrix validation only for merge request events
33
+ - **ci**: generate ruby version matrix only for versions with valid docker images
34
+ - **appraisals**: make appraisal gem versions always deterministic by tracking lock files and update them via renovate
35
+ lockFileMaintenance
36
+ - **coverage**: explicitly track all relevant ruby files, even if they don't get required
37
+ - **ci**: make pipeline jobs interruptible by default to support canceling redundant pipelines
38
+ - **coverage**: enable coverage in CI and exclude temporary, untested code from coverage
39
+ - **rubocop**: make it pass by disabling offenses on temporary code
data/README.md CHANGED
@@ -1 +1,3 @@
1
1
  # SorbetTyped::ShortCircuit
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/sorbet_typed-short_circuit.svg?icon=si%3Arubygems)](https://badge.fury.io/rb/sorbet_typed-short_circuit)
@@ -1,13 +1,13 @@
1
1
  # typed: false # rubocop:disable Sorbet/HasSigil -- type for this gets defined by rbi/sorbet_typed/short_circuit/circuit_breaker.rbi
2
2
  # frozen_string_literal: true
3
3
 
4
- # HACK: monkey patching the circuit breaker to have an untyped call method. It's
5
- # signatures get provided by rbi/sorbet_typed/short_circuit/circuit_breaker.rbi
6
- # to support overloads.
7
-
8
4
  module SorbetTyped
9
5
  class ShortCircuit
10
- class CircuitBreaker # rubocop:disable Style/Documentation -- documentation comment exists on the main implementation of this class
6
+ # HACK: monkey patching the circuit breaker to have an untyped call method. It's
7
+ # signatures get provided by rbi/sorbet_typed/short_circuit/circuit_breaker.rbi
8
+ # to support overloads.
9
+ # -- documentation comment exists on the main implementation of this class
10
+ class CircuitBreaker
11
11
  def call(result)
12
12
  case result
13
13
  when SorbetTyped::ShortCircuit::Signals::Shorted
@@ -3,6 +3,18 @@
3
3
 
4
4
  module SorbetTyped
5
5
  class ShortCircuit
6
+ # Module to be used in type signatures to allow passing CircuitBreaker
7
+ # instances around. This module is publicly available, in contrast to the
8
+ # CircuitBreaker class.
9
+ module CircuitBreakerType
10
+ extend T::Generic
11
+ extend T::Helpers
12
+
13
+ sealed!
14
+
15
+ ShortedResult = type_member
16
+ end
17
+
6
18
  # Callable implementing the logic to fail fast if the input is a Shorted
7
19
  # signal. To be used like Dry::Monads `yield foo` syntax.
8
20
  #
@@ -11,6 +23,8 @@ module SorbetTyped
11
23
  extend T::Sig
12
24
  extend T::Generic
13
25
 
26
+ include CircuitBreakerType
27
+
14
28
  ShortedResult = type_member
15
29
 
16
30
  private
@@ -24,6 +24,7 @@ module SorbetTyped
24
24
  # and other low level ruby stuff.
25
25
  ########################################################################
26
26
  sig { params(klass: ::T::Class[::T.anything]).returns(::T::Boolean) }
27
+ # :reek:UtilityFunction -- because the class inherits from BasicObject, self.class cannot be used
27
28
  def is_a?(klass)
28
29
  klass == Shorted
29
30
  end
@@ -44,6 +45,11 @@ module SorbetTyped
44
45
  end
45
46
 
46
47
  sig { params(method_name: ::Symbol, _include_all: ::T::Boolean).returns(::T::Boolean) }
48
+ # :reek:BooleanParameter -- mirroring the respond_to? implementation
49
+ # from Object
50
+ #
51
+ # :reek:UtilityFunction -- this object responds to only one method. It's
52
+ # ok to not get it from instance state.
47
53
  def respond_to?(method_name, _include_all = false) # rubocop:disable Style/OptionalBooleanParameter -- mirroring the respond_to? implementation from Object
48
54
  method_name == :payload
49
55
  end
@@ -6,7 +6,7 @@
6
6
  # -- Disabled, because this file gets required in gemspec, where zeitwerk is not active
7
7
  module SorbetTyped
8
8
  class ShortCircuit
9
- VERSION = '0.1.0'
9
+ VERSION = '1.0.1'
10
10
  end
11
11
  end
12
12
 
@@ -91,25 +91,21 @@ module SorbetTyped
91
91
  self.short_circuited = false
92
92
  yield(CircuitBreaker[ShortedResult].new(circuit_id: object_id))
93
93
  rescue Errors::CircuitShorted => exception
94
- # This ensures, the circuit can only be broken by a circuit shorted
95
- # exception raised in it's own circuit breaker. Everything else is
96
- # re-raised.
97
- raise exception unless exception.circuit_id == object_id
98
-
99
- self.short_circuited = true
100
-
101
- # NOTE: sorbet is only able to detect
102
- # `SorbetTyped::ShortCircuit::CircuitShortedError[T.anything]` in this
103
- # rescue. But because it must come from `CircuitBreaker[ShortedResult]`,
104
- # it will also always be
105
- # `CircuitShortedError[SorbetTyped::ShortCircuit::Shorted[ShortedResult]]`.
106
- # So we tell that to sorbet.
107
- #
108
- # Unfortunately, because sorbet erases generic types at runtime, this
109
- # cannot be ensured at runtime. Type-safety is still ensured, because the
110
- # error and circuit breaker classes are private and can neither be
111
- # instantiated, thrown or rescued (coding "normally").
112
- T.cast(exception, Errors::CircuitShorted[SorbetTyped::ShortCircuit::Signals::Shorted[ShortedResult]]).signal
94
+ handle_shorted_circuit(
95
+ shorted_exception:
96
+ # NOTE: sorbet is only able to detect
97
+ # `SorbetTyped::ShortCircuit::CircuitShortedError[T.anything]` in this
98
+ # rescue. But because it must come from `CircuitBreaker[ShortedResult]`,
99
+ # it will also always be
100
+ # `CircuitShortedError[SorbetTyped::ShortCircuit::Shorted[ShortedResult]]`.
101
+ # So we tell that to sorbet.
102
+ #
103
+ # Unfortunately, because sorbet erases generic types at runtime, this
104
+ # cannot be ensured at runtime. Type-safety is still ensured, because the
105
+ # error and circuit breaker classes are private and can neither be
106
+ # instantiated, thrown or rescued (coding "normally").
107
+ T.cast(exception, Errors::CircuitShorted[SorbetTyped::ShortCircuit::Signals::Shorted[ShortedResult]])
108
+ )
113
109
  end
114
110
 
115
111
  sig do
@@ -143,5 +139,24 @@ module SorbetTyped
143
139
  end
144
140
 
145
141
  # TODO: #success? method
142
+
143
+ private
144
+
145
+ sig do
146
+ params(
147
+ shorted_exception: Errors::CircuitShorted[SorbetTyped::ShortCircuit::Signals::Shorted[ShortedResult]]
148
+ ).
149
+ returns(Signals::Shorted[ShortedResult])
150
+ end
151
+ def handle_shorted_circuit(shorted_exception:)
152
+ # This ensures, the circuit can only be broken by a circuit shorted
153
+ # exception raised in it's own circuit breaker. Everything else is
154
+ # re-raised.
155
+ raise shorted_exception unless shorted_exception.circuit_id == object_id
156
+
157
+ self.short_circuited = true
158
+
159
+ shorted_exception.signal
160
+ end
146
161
  end
147
162
  end
@@ -2,12 +2,32 @@
2
2
 
3
3
  module SorbetTyped
4
4
  class ShortCircuit
5
+ module CircuitBreakerType
6
+ # NOTE: providing overloads here, because the possible input and output
7
+ # cases cannot be fully modeled using a single signature within the actual
8
+ # class.
9
+ sig { params(result: SorbetTyped::ShortCircuit::Signals::Shorted[ShortedResult]).returns(T.noreturn) }
10
+ sig do
11
+
12
+ type_parameters(:SuccessType).
13
+ params(
14
+ result: T.any(
15
+ SorbetTyped::ShortCircuit::Signals::Shorted[ShortedResult],
16
+ T.all(T.type_parameter(:SuccessType), Object)
17
+ )
18
+ ).
19
+ returns(T.all(T.type_parameter(:SuccessType), Object))
20
+ end
21
+ def call(result); end
22
+ end
23
+
5
24
  class CircuitBreaker
6
25
  # NOTE: providing overloads here, because the possible input and output
7
26
  # cases cannot be fully modeled using a single signature within the actual
8
27
  # class.
9
28
  sig { params(result: SorbetTyped::ShortCircuit::Signals::Shorted[ShortedResult]).returns(T.noreturn) }
10
29
  sig do
30
+
11
31
  type_parameters(:SuccessType).
12
32
  params(
13
33
  result: T.any(
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sorbet_typed-short_circuit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Kramer
@@ -36,7 +36,10 @@ executables: []
36
36
  extensions: []
37
37
  extra_rdoc_files: []
38
38
  files:
39
+ - ".cz.yaml"
40
+ - ".pre-commit-config.yaml"
39
41
  - ".shellcheckrc.tmp"
42
+ - CHANGELOG.md
40
43
  - COPYING
41
44
  - README.md
42
45
  - lib/sorbet_typed/short_circuit.rb