diff --git a/apps/client/src/features/modals/integration-modal/http/HttpIntegration.tsx b/apps/client/src/features/modals/integration-modal/http/HttpIntegration.tsx index 450d4d232..c32bca05f 100644 --- a/apps/client/src/features/modals/integration-modal/http/HttpIntegration.tsx +++ b/apps/client/src/features/modals/integration-modal/http/HttpIntegration.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from 'react'; import { useForm } from 'react-hook-form'; -import { Switch } from '@chakra-ui/react'; +import { Input, Switch } from '@chakra-ui/react'; import type { HttpSettings } from 'ontime-types'; import { TimerLifeCycle } from 'ontime-types'; @@ -49,6 +49,7 @@ export default function HttpIntegration() { try { const newSettings: HttpSettings = { enabledOut: Boolean(values.enabledOut), + retryCount: 0, subscriptions: { onLoad: values.subscriptions.onLoad ?? [], onStart: values.subscriptions.onStart ?? [], @@ -79,6 +80,14 @@ export default function HttpIntegration() { +
+
+ Retry count + How many times should the connection be retried +
+ +
+ { // protected httpAgent: null | http.Agent; subscriptions: HttpSubscription; - + private retryCount = 0; constructor() { // this.httpAgent = null; this.subscriptions = dbModel.http.subscriptions; @@ -27,7 +27,9 @@ export class HttpIntegration implements IIntegration { * Initializes httpClient */ init(config: HttpSettings) { - const { subscriptions, enabledOut } = config; + const { subscriptions, enabledOut, retryCount } = config; + + this.retryCount = retryCount; if (!enabledOut) { // this.httpAgent?.destroy(); @@ -102,12 +104,12 @@ export class HttpIntegration implements IIntegration { if (method === 'GET') { await got.get(path, { searchParams: options, - retry: { limit: 0 }, + retry: { limit: this.retryCount }, }); } else if (method === 'POST') { await got.post(path, { body: options, - retry: { limit: 0 }, + retry: { limit: this.retryCount }, }); } } catch (err) { diff --git a/apps/server/src/utils/parserFunctions.ts b/apps/server/src/utils/parserFunctions.ts index 5000a0d86..4d0aea0e5 100644 --- a/apps/server/src/utils/parserFunctions.ts +++ b/apps/server/src/utils/parserFunctions.ts @@ -280,8 +280,11 @@ export const parseHttp = (data: { http?: Partial }): HttpSettings ? loadedConfig.subscriptions : dbModel.http.subscriptions; + const retryCount = Math.max(0, loadedConfig.retryCount ?? dbModel.http.retryCount); + return { enabledOut: loadedConfig.enabledOut ?? dbModel.http.enabledOut, + retryCount: retryCount, subscriptions: validatedSubscriptions, }; } diff --git a/packages/types/src/definitions/core/HttpSettings.type.ts b/packages/types/src/definitions/core/HttpSettings.type.ts index fe592c36f..cd133d840 100644 --- a/packages/types/src/definitions/core/HttpSettings.type.ts +++ b/packages/types/src/definitions/core/HttpSettings.type.ts @@ -6,5 +6,6 @@ export type HttpSubscription = Subscription; export interface HttpSettings { enabledOut: boolean; + retryCount: number; subscriptions: HttpSubscription; }