mirror of
https://github.com/block/goose.git
synced 2026-07-17 12:56:20 +02:00
58 lines
2.4 KiB
Swift
58 lines
2.4 KiB
Swift
//
|
|
// RetryConfig.swift
|
|
//
|
|
// Generated by openapi-generator
|
|
// https://openapi-generator.tech
|
|
//
|
|
|
|
import Foundation
|
|
#if canImport(AnyCodable)
|
|
import AnyCodable
|
|
#endif
|
|
|
|
/** Configuration for retry logic in recipe execution */
|
|
public struct RetryConfig: Codable, JSONEncodable, Hashable {
|
|
|
|
public static let maxRetriesRule = NumericRule<Int>(minimum: 0, exclusiveMinimum: false, maximum: nil, exclusiveMaximum: false, multipleOf: nil)
|
|
public static let onFailureTimeoutSecondsRule = NumericRule<Int64>(minimum: 0, exclusiveMinimum: false, maximum: nil, exclusiveMaximum: false, multipleOf: nil)
|
|
public static let timeoutSecondsRule = NumericRule<Int64>(minimum: 0, exclusiveMinimum: false, maximum: nil, exclusiveMaximum: false, multipleOf: nil)
|
|
/** List of success checks to validate recipe completion */
|
|
public var checks: [SuccessCheck]
|
|
/** Maximum number of retry attempts before giving up */
|
|
public var maxRetries: Int
|
|
/** Optional shell command to run on failure for cleanup */
|
|
public var onFailure: String?
|
|
/** Timeout in seconds for on_failure commands (default: 600 seconds) */
|
|
public var onFailureTimeoutSeconds: Int64?
|
|
/** Timeout in seconds for individual shell commands (default: 300 seconds) */
|
|
public var timeoutSeconds: Int64?
|
|
|
|
public init(checks: [SuccessCheck], maxRetries: Int, onFailure: String? = nil, onFailureTimeoutSeconds: Int64? = nil, timeoutSeconds: Int64? = nil) {
|
|
self.checks = checks
|
|
self.maxRetries = maxRetries
|
|
self.onFailure = onFailure
|
|
self.onFailureTimeoutSeconds = onFailureTimeoutSeconds
|
|
self.timeoutSeconds = timeoutSeconds
|
|
}
|
|
|
|
public enum CodingKeys: String, CodingKey, CaseIterable {
|
|
case checks
|
|
case maxRetries = "max_retries"
|
|
case onFailure = "on_failure"
|
|
case onFailureTimeoutSeconds = "on_failure_timeout_seconds"
|
|
case timeoutSeconds = "timeout_seconds"
|
|
}
|
|
|
|
// Encodable protocol methods
|
|
|
|
public func encode(to encoder: Encoder) throws {
|
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
|
try container.encode(checks, forKey: .checks)
|
|
try container.encode(maxRetries, forKey: .maxRetries)
|
|
try container.encodeIfPresent(onFailure, forKey: .onFailure)
|
|
try container.encodeIfPresent(onFailureTimeoutSeconds, forKey: .onFailureTimeoutSeconds)
|
|
try container.encodeIfPresent(timeoutSeconds, forKey: .timeoutSeconds)
|
|
}
|
|
}
|
|
|