Skip to content

Commit

Permalink
[B] Refactor AdoptOrOrphan job
Browse files Browse the repository at this point in the history
* Add uniqueness to the job to prevent multiple adoptions for a single
  annotation
* Add cyclical detections and execution time limits
  * Restrict an attempt to locate the character positions from
    iterating endlessly
  * Monitor execution time on various iterations / recursions and
    bail out if it is taking too long
* Any bailout action will orphan the annotation

Resolves RET-1728
  • Loading branch information
scryptmouse authored and zdavis committed Aug 20, 2024
1 parent 3aebc76 commit 6fbab30
Show file tree
Hide file tree
Showing 4 changed files with 237 additions and 87 deletions.
10 changes: 9 additions & 1 deletion api/app/jobs/annotation_jobs/adopt_or_orphan_job.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# frozen_string_literal: true

module AnnotationJobs
# @see Annotations::AdoptOrOrphan
class AdoptOrOrphanJob < ApplicationJob
queue_as :annotations

unique :until_executed, lock_ttl: 15.minutes, on_conflict: :log

# @param [Annotation] annotation
# @return [void]
def perform(annotation)
Annotations::AdoptOrOrphan.run annotation: annotation
Annotations::AdoptOrOrphan.run! annotation: annotation
end
end
end
Loading

0 comments on commit 6fbab30

Please sign in to comment.