Skip to content

Commit

Permalink
Use main, job id parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-fowler committed Mar 11, 2024
1 parent 5643629 commit 436889d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let package = Package(
.library(name: "HummingbirdPostgres", targets: ["HummingbirdPostgres"]),
],
dependencies: [
.package(url: "https://github.com/hummingbird-project/hummingbird.git", branch: "remove-hb-prefix"),
.package(url: "https://github.com/hummingbird-project/hummingbird.git", branch: "main"),
.package(url: "https://github.com/vapor/postgres-nio", from: "1.20.0"),
],
targets: [
Expand Down
12 changes: 6 additions & 6 deletions Tests/HummingbirdPostgresTests/JobsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ final class JobsTests: XCTestCase {
let expectation = XCTestExpectation(description: "TestJob.execute was called", expectedFulfillmentCount: 10)
let jobIdentifer = JobIdentifier<Int>(#function)
try await self.testJobQueue(numWorkers: 1) { jobQueue in
jobQueue.registerJob(jobIdentifer) { parameters, context in
jobQueue.registerJob(id: jobIdentifer) { parameters, context in
context.logger.info("Parameters=\(parameters)")
try await Task.sleep(for: .milliseconds(Int.random(in: 10..<50)))
expectation.fulfill()
Expand All @@ -157,7 +157,7 @@ final class JobsTests: XCTestCase {
let expectation = XCTestExpectation(description: "TestJob.execute was called", expectedFulfillmentCount: 10)

try await self.testJobQueue(numWorkers: 4) { jobQueue in
jobQueue.registerJob(jobIdentifer) { parameters, context in
jobQueue.registerJob(id: jobIdentifer) { parameters, context in
let runningJobs = runningJobCounter.wrappingIncrementThenLoad(by: 1, ordering: .relaxed)
if runningJobs > maxRunningJobCounter.load(ordering: .relaxed) {
maxRunningJobCounter.store(runningJobs, ordering: .relaxed)
Expand Down Expand Up @@ -191,7 +191,7 @@ final class JobsTests: XCTestCase {
let expectation = XCTestExpectation(description: "TestJob.execute was called", expectedFulfillmentCount: 4)
struct FailedError: Error {}
try await self.testJobQueue(numWorkers: 1) { jobQueue in
jobQueue.registerJob(jobIdentifer, maxRetryCount: 3) { _, _ in
jobQueue.registerJob(id: jobIdentifer, maxRetryCount: 3) { _, _ in
expectation.fulfill()
throw FailedError()
}
Expand All @@ -215,7 +215,7 @@ final class JobsTests: XCTestCase {
let expectation = XCTestExpectation(description: "TestJob.execute was called")
let jobIdentifer = JobIdentifier<TestJobParameters>(#function)
try await self.testJobQueue(numWorkers: 1) { jobQueue in
jobQueue.registerJob(jobIdentifer) { parameters, _ in
jobQueue.registerJob(id: jobIdentifer) { parameters, _ in
XCTAssertEqual(parameters.id, 23)
XCTAssertEqual(parameters.message, "Hello!")
expectation.fulfill()
Expand All @@ -232,7 +232,7 @@ final class JobsTests: XCTestCase {
let expectation = XCTestExpectation(description: "TestJob.execute was called", expectedFulfillmentCount: 1)

try await self.testJobQueue(numWorkers: 4) { jobQueue in
jobQueue.registerJob(jobIdentifer) { _, _ in
jobQueue.registerJob(id: jobIdentifer) { _, _ in
expectation.fulfill()
try await Task.sleep(for: .milliseconds(1000))
}
Expand All @@ -255,7 +255,7 @@ final class JobsTests: XCTestCase {
let expectation = XCTestExpectation(description: "job was called", expectedFulfillmentCount: 1)

try await self.testJobQueue(numWorkers: 4) { jobQueue in
jobQueue.registerJob(jobIdentifer2) { parameters, _ in
jobQueue.registerJob(id: jobIdentifer2) { parameters, _ in
string.withLockedValue { $0 = parameters }
expectation.fulfill()
}
Expand Down

0 comments on commit 436889d

Please sign in to comment.