Skip to content

Commit 4538628

Browse files
cardmagicclaude
andcommitted
refactor: inline the one-use redrive helpers
`active_scope_for` wrapped one interpolation and `batch_size` wrapped one calculation, each with a single caller. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent a954bb1 commit 4538628

4 files changed

Lines changed: 4 additions & 22 deletions

File tree

‎lib/solid_objects/redrive_manager.rb‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class RedriveManager
1111
# @rbs (scope: DeadLetterScope, filters: Hash[String, untyped], authorization_context: untyped) -> RedriveTask
1212
def start(scope:, filters:, authorization_context:)
1313
scope.authorize!(:redrive, authorization_context:)
14-
active_scope = active_scope_for(kind: scope.kind, filters:)
14+
active_scope = "#{scope.kind}:#{Digest::SHA256.hexdigest(filters.to_json)}"
1515
running = Redrive.find_by(active_scope:)
1616
return task_for(running) if running
1717

@@ -114,11 +114,6 @@ def remaining_for(record)
114114
[ matching, limit - record.moved ].min
115115
end
116116

117-
# @rbs (kind: String, filters: Hash[String, untyped]) -> String
118-
def active_scope_for(kind:, filters:)
119-
"#{kind}:#{Digest::SHA256.hexdigest(filters.to_json)}"
120-
end
121-
122117
# @rbs (Symbol, authorization_context: untyped, ?resource_id: String?) -> void
123118
def authorize!(action, authorization_context:, resource_id: nil)
124119
authorized = SolidObjects.configuration.authorize_administration.call(

‎lib/solid_objects/redrive_runner.rb‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ def advance(record)
3232
# @rbs (Redrive) -> Integer
3333
def move_batch(record)
3434
scope = DeadLetterScope.for_kind(record.kind)
35-
size = batch_size(record)
35+
configured = SolidObjects.configuration.redrive_batch_size
36+
limit = record.move_limit
37+
size = limit ? [ configured, limit - record.moved ].min : configured
3638
return 0 unless size.positive?
3739

3840
identifiers = scope
@@ -47,15 +49,6 @@ def move_batch(record)
4749
revived
4850
end
4951

50-
# @rbs (Redrive) -> Integer
51-
def batch_size(record)
52-
configured = SolidObjects.configuration.redrive_batch_size
53-
limit = record.move_limit
54-
return configured unless limit
55-
56-
[ configured, limit - record.moved ].min
57-
end
58-
5952
# @rbs (Redrive) -> void
6053
def finish(record)
6154
manager = SolidObjects.redrives

‎sig/generated/lib/solid_objects/redrive_manager.rbs‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ module SolidObjects
3737
# @rbs (Redrive) -> Integer
3838
def remaining_for: (Redrive) -> Integer
3939

40-
# @rbs (kind: String, filters: Hash[String, untyped]) -> String
41-
def active_scope_for: (kind: String, filters: Hash[String, untyped]) -> String
42-
4340
# @rbs (Symbol, authorization_context: untyped, ?resource_id: String?) -> void
4441
def authorize!: (Symbol, authorization_context: untyped, ?resource_id: String?) -> void
4542
end

‎sig/generated/lib/solid_objects/redrive_runner.rbs‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ module SolidObjects
1616
# @rbs (Redrive) -> Integer
1717
def move_batch: (Redrive) -> Integer
1818

19-
# @rbs (Redrive) -> Integer
20-
def batch_size: (Redrive) -> Integer
21-
2219
# @rbs (Redrive) -> void
2320
def finish: (Redrive) -> void
2421
end

0 commit comments

Comments
 (0)