Skip to content

Commit

Permalink
Remove Hummingbird dependency from HummingbirdJobs
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-fowler committed Feb 27, 2024
1 parent 3afb86b commit 8a898a6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
6 changes: 5 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/apple/swift-async-algorithms.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-atomics.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-collections.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.4.0"),
.package(url: "https://github.com/apple/swift-http-types.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-metrics.git", "1.0.0"..<"3.0.0"),
Expand Down Expand Up @@ -70,8 +71,10 @@ let package = Package(
.target(
name: "HummingbirdJobs",
dependencies: [
.byName(name: "Hummingbird"),
.product(name: "Collections", package: "swift-collections"),
.product(name: "Logging", package: "swift-log"),
.product(name: "NIOConcurrencyHelpers", package: "swift-nio"),
.product(name: "ServiceLifecycle", package: "swift-service-lifecycle"),
],
swiftSettings: swiftSettings
),
Expand Down Expand Up @@ -138,6 +141,7 @@ let package = Package(
.testTarget(name: "HummingbirdJobsTests", dependencies: [
.byName(name: "HummingbirdJobs"),
.byName(name: "HummingbirdXCT"),
.product(name: "Atomics", package: "swift-atomics"),
]),
.testTarget(name: "HummingbirdRouterTests", dependencies: [
.byName(name: "HummingbirdRouter"),
Expand Down
13 changes: 5 additions & 8 deletions Sources/HummingbirdJobs/JobQueue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
//===----------------------------------------------------------------------===//

import Foundation
import Hummingbird
import Logging
import ServiceLifecycle

Expand Down Expand Up @@ -43,7 +42,7 @@ public struct HBJobQueue<Queue: HBJobQueueDriver>: Service {
return try await self.queue.push(data: data)
}

/// Register job
/// Register job type
/// - Parameters:
/// - id: Job Identifier
/// - maxRetryCount: Maximum number of times job is retried before being flagged as failed
Expand All @@ -57,15 +56,13 @@ public struct HBJobQueue<Queue: HBJobQueueDriver>: Service {
) async throws -> Void
) {
let job = HBJobDefinition<Parameters>(id: id, maxRetryCount: maxRetryCount, execute: execute)
self.handler.registerJob(job)
self.registerJob(job)
}

/// Register job
/// Register job type
/// - Parameters:
/// - id: Job Identifier
/// - maxRetryCount: Maximum number of times job is retried before being flagged as failed
/// - execute: Job code
public func registerJob(_ job: HBJobDefinition<some Codable & Sendable>) {
/// - job: Job definition
public func registerJob<Parameters: Codable & Sendable>(_ job: HBJobDefinition<Parameters>) {
self.handler.registerJob(job)
}

Expand Down
1 change: 0 additions & 1 deletion Sources/HummingbirdJobs/JobQueueDriver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
//===----------------------------------------------------------------------===//

import Foundation
import Hummingbird
import Logging

/// Job queue protocol.
Expand Down
2 changes: 0 additions & 2 deletions Sources/HummingbirdJobs/JobQueueHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
//
//===----------------------------------------------------------------------===//

import AsyncAlgorithms
import Hummingbird
import Logging
import ServiceLifecycle

Expand Down

0 comments on commit 8a898a6

Please sign in to comment.