Skip to content

Commit

Permalink
Add precondition to check job isn't registered twice
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-fowler committed Feb 26, 2024
1 parent da147fd commit 63c24d9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Sources/HummingbirdJobs/JobRegister.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ public enum HBJobRegister {
let parameters = try Parameters(from: decoder)
return try HBJobInstance(job: definition, parameters: parameters)
}
self.idTypeMap.withLockedValue { $0[id.name] = builder }
self.idTypeMap.withLockedValue {
precondition($0[id.name] == nil, "There is a job already registered under id \"\(id.name)\"")
$0[id.name] = builder
}
}

static func decode(from decoder: Decoder) throws -> any HBJob {
Expand Down

0 comments on commit 63c24d9

Please sign in to comment.