From 28e7090da1ec2a3711f660263edf37f78506a68b Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 2 Nov 2024 20:08:36 -0500 Subject: add timeout and retry options for webhooks --- src/slskd/Core/Options.cs | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index a9d6aeb8..e5f16b1e 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -2044,13 +2044,25 @@ namespace slskd /// Gets details about the webhook call. /// [Validate] - public WebhookDetails Call { get; init; } = new WebhookDetails(); + public WebhookHttpOptions Call { get; init; } = new WebhookHttpOptions(); + + /// + /// Gets the time to wait before timing out, in milliseconds. + /// + [Range(500, int.MaxValue)] + public int Timeout { get; init; } = 5000; + + /// + /// Gets the retry configuration. + /// + [Validate] + public RetryOptions Retry { get; init; } = new RetryOptions(); } /// - /// Webhook details. + /// Webhook HTTP options. /// - public class WebhookDetails : IValidatableObject + public class WebhookHttpOptions : IValidatableObject { /// /// Gets the fully qualified URL for the webhook. @@ -2062,7 +2074,7 @@ namespace slskd /// Gets the HTTP headers to include with the webhook. /// [Validate] - public WebhookDetailHeader[] Headers { get; init; } = []; + public WebhookHttpHeader[] Headers { get; init; } = []; /// /// Gets a value indicating whether HTTPS certificate errors should be ignored. @@ -2082,13 +2094,35 @@ namespace slskd } } - public class WebhookDetailHeader + /// + /// Webhook HTTP header configuration. + /// + public class WebhookHttpHeader { + /// + /// Gets the name of the header. + /// [NotNullOrWhiteSpace] public string Name { get; init; } + + /// + /// Gets the header's value. + /// public string Value { get; init; } } + /// + /// Retry configuration. + /// + public class RetryOptions + { + /// + /// Gets the number of attempts to make before failing. + /// + [Range(1, int.MaxValue)] + public int Attempts { get; init; } = 1; + } + /// /// Script configuration. /// -- cgit v1.2.3