diff --git a/.changeset/strong-planes-return.md b/.changeset/strong-planes-return.md new file mode 100644 index 0000000000..d7f02934c9 --- /dev/null +++ b/.changeset/strong-planes-return.md @@ -0,0 +1,6 @@ +--- +'@backstage/plugin-tech-insights-backend': minor +'@backstage/plugin-tech-insights-node': minor +--- + +Support for timeout in FactRetrieverRegistrationOptions diff --git a/plugins/tech-insights-backend/src/service/fact/createFactRetriever.ts b/plugins/tech-insights-backend/src/service/fact/createFactRetriever.ts index de49888e1b..c14cc260f9 100644 --- a/plugins/tech-insights-backend/src/service/fact/createFactRetriever.ts +++ b/plugins/tech-insights-backend/src/service/fact/createFactRetriever.ts @@ -13,11 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { HumanDuration } from '@backstage/backend-tasks'; import { FactLifecycle, FactRetriever, FactRetrieverRegistration, } from '@backstage/plugin-tech-insights-node'; +import { Duration } from 'luxon'; /** * @public @@ -31,6 +33,7 @@ export type FactRetrieverRegistrationOptions = { cadence: string; factRetriever: FactRetriever; lifecycle?: FactLifecycle; + timeout: Duration | HumanDuration; }; /** @@ -64,10 +67,11 @@ export type FactRetrieverRegistrationOptions = { export function createFactRetrieverRegistration( options: FactRetrieverRegistrationOptions, ): FactRetrieverRegistration { - const { cadence, factRetriever, lifecycle } = options; + const { cadence, factRetriever, lifecycle, timeout } = options; return { cadence, factRetriever, lifecycle, + timeout, }; } diff --git a/plugins/tech-insights-node/package.json b/plugins/tech-insights-node/package.json index 0233fac050..355806bdfa 100644 --- a/plugins/tech-insights-node/package.json +++ b/plugins/tech-insights-node/package.json @@ -34,6 +34,7 @@ }, "dependencies": { "@backstage/backend-common": "^0.15.0", + "@backstage/backend-tasks": "^0.3.4", "@backstage/config": "^1.0.1", "@backstage/plugin-tech-insights-common": "^0.2.6", "@backstage/types": "^1.0.0", diff --git a/plugins/tech-insights-node/src/facts.ts b/plugins/tech-insights-node/src/facts.ts index cda238694f..41db302fd5 100644 --- a/plugins/tech-insights-node/src/facts.ts +++ b/plugins/tech-insights-node/src/facts.ts @@ -21,6 +21,7 @@ import { TokenManager, } from '@backstage/backend-common'; import { Logger } from 'winston'; +import { HumanDuration } from '@backstage/backend-tasks'; /** * A container for facts. The shape of the fact records needs to correspond to the FactSchema with same `ref` value. @@ -270,7 +271,7 @@ export type FactRetrieverRegistration = { * defaults to 5 minutes. * */ - timeout?: Duration; + timeout?: Duration | HumanDuration; /** * Fact lifecycle definition