/
Job.swift
32 lines (30 loc) · 1012 Bytes
/
Job.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//===----------------------------------------------------------------------===//
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2024 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
/// Protocol for a Job
public protocol HBJob: Sendable {
/// Parameters job requries
associatedtype Parameters: Codable & Sendable
/// Job Type identifier
var id: HBJobIdentifier<Parameters> { get }
/// Maximum number of times a job will be retried before being classed as failed
var maxRetryCount: Int { get }
/// Function to execute the job
func execute(context: HBJobContext) async throws
}
extension HBJob {
/// name of job type
public var name: String {
id.name
}
}