Skip to content

Commit 3c0c8a1

Browse files
committed
.doNotRetain
1 parent f4bbb60 commit 3c0c8a1

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

Sources/JobsPostgres/PostgresJobsQueue.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public final class PostgresJobQueue: JobQueueDriver, CancellableJobQueue, Resuma
197197
public func cancel(jobID: JobID) async throws {
198198
try await self.client.withTransaction(logger: logger) { connection in
199199
try await deleteFromQueue(jobID: jobID, connection: connection)
200-
if configuration.retentionPolicy.cancelled == .never {
200+
if configuration.retentionPolicy.cancelled == .doNotRetain {
201201
try await delete(jobID: jobID)
202202
} else {
203203
try await setStatus(jobID: jobID, status: .cancelled, connection: connection)
@@ -278,7 +278,7 @@ public final class PostgresJobQueue: JobQueueDriver, CancellableJobQueue, Resuma
278278

279279
/// This is called to say job has finished processing and it can be deleted
280280
public func finished(jobID: JobID) async throws {
281-
if configuration.retentionPolicy.completed == .never {
281+
if configuration.retentionPolicy.completed == .doNotRetain {
282282
try await self.delete(jobID: jobID)
283283
} else {
284284
try await self.setStatus(jobID: jobID, status: .completed)
@@ -287,7 +287,7 @@ public final class PostgresJobQueue: JobQueueDriver, CancellableJobQueue, Resuma
287287

288288
/// This is called to say job has failed to run and should be put aside
289289
public func failed(jobID: JobID, error: Error) async throws {
290-
if configuration.retentionPolicy.failed == .never {
290+
if configuration.retentionPolicy.failed == .doNotRetain {
291291
try await self.delete(jobID: jobID)
292292
} else {
293293
try await self.setStatus(jobID: jobID, status: .failed)

Sources/JobsPostgres/RetentionPolicy.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,19 @@ public struct RetentionPolicy: Sendable {
2727
/// Retain task
2828
public static var retain: RetainData { RetainData(rawValue: .retain) }
2929
/// Never retain any data
30-
public static var never: RetainData { RetainData(rawValue: .doNotRetain) }
30+
public static var doNotRetain: RetainData { RetainData(rawValue: .doNotRetain) }
3131
}
3232

3333
/// Jobs with status cancelled
34-
/// default retention is set for 7 days
3534
public var cancelled: RetainData
3635
/// Jobs with status completed
37-
/// default retention is set to 7 days
3836
public var completed: RetainData
3937
/// Jobs with status failed
40-
/// default retention is set to 30 days
4138
public var failed: RetainData
4239

4340
public init(
44-
cancelled: RetainData = .retain,
45-
completed: RetainData = .never,
41+
cancelled: RetainData = .doNotRetain,
42+
completed: RetainData = .doNotRetain,
4643
failed: RetainData = .retain
4744
) {
4845
self.cancelled = cancelled

Tests/JobsPostgresTests/JobsTests.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -499,9 +499,9 @@ final class JobsTests: XCTestCase {
499499
numWorkers: 4,
500500
configuration: .init(
501501
retentionPolicy: .init(
502-
cancelled: .never,
503-
completed: .never,
504-
failed: .never
502+
cancelled: .doNotRetain,
503+
completed: .doNotRetain,
504+
failed: .doNotRetain
505505
)
506506
)
507507
) { jobQueue in
@@ -787,9 +787,9 @@ final class JobsTests: XCTestCase {
787787
numWorkers: 1,
788788
configuration: .init(
789789
retentionPolicy: .init(
790-
cancelled: .never,
791-
completed: .never,
792-
failed: .never
790+
cancelled: .doNotRetain,
791+
completed: .doNotRetain,
792+
failed: .doNotRetain
793793
)
794794
),
795795
function: #function
@@ -893,7 +893,7 @@ final class JobsTests: XCTestCase {
893893
configuration: .init(
894894
retentionPolicy: .init(
895895
cancelled: .retain,
896-
completed: .never,
896+
completed: .doNotRetain,
897897
failed: .retain
898898
)
899899
)
@@ -904,7 +904,7 @@ final class JobsTests: XCTestCase {
904904
queueName: "SecondQueue",
905905
retentionPolicy: .init(
906906
cancelled: .retain,
907-
completed: .never,
907+
completed: .doNotRetain,
908908
failed: .retain
909909
)
910910
)

0 commit comments

Comments
 (0)