Skip to content

Make sure we have unique keys per queue for queue metadata #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Sources/JobsRedis/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ extension RedisJobQueue {
let queueKey: RedisKey
let processingQueueKey: RedisKey
let failedQueueKey: RedisKey
let metadataKeyPrefix: String
let pollTime: Duration

public init(
queueKey: String = "_hbJobQueue",
pollTime: Duration = .milliseconds(100)
) {
self.queueKey = RedisKey(queueKey)
self.processingQueueKey = RedisKey("\(queueKey)Processing")
self.failedQueueKey = RedisKey("\(queueKey)Failed")
self.queueKey = RedisKey("\(queueKey).pending")
self.processingQueueKey = RedisKey("\(queueKey).processing")
self.failedQueueKey = RedisKey("\(queueKey).failed")
self.metadataKeyPrefix = "\(queueKey).metadata"
self.pollTime = pollTime
}
}
Expand Down
4 changes: 3 additions & 1 deletion Sources/JobsRedis/RedisJobQueue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,16 @@ public final class RedisJobQueue: JobQueueDriver {
/// - Parameter key: Metadata key
/// - Returns: Associated ByteBuffer
public func getMetadata(_ key: String) async throws -> ByteBuffer? {
try await self.redisConnectionPool.wrappedValue.get(.init(key)).get().byteBuffer
let key = "\(self.configuration.metadataKeyPrefix).\(key)"
return try await self.redisConnectionPool.wrappedValue.get(.init(key)).get().byteBuffer
}

/// Set job queue metadata
/// - Parameters:
/// - key: Metadata key
/// - value: Associated ByteBuffer
public func setMetadata(key: String, value: ByteBuffer) async throws {
let key = "\(self.configuration.metadataKeyPrefix).\(key)"
try await self.redisConnectionPool.wrappedValue.set(.init(key), to: value).get()
}

Expand Down
Loading