UNPKG

@mdf.js/openc2-core

Version:

MMS - API Core - OpenC2

74 lines 2.96 kB
/** * Copyright 2024 Mytra Control S.L. All rights reserved. * * Use of this source code is governed by an MIT-style license that can be found in the LICENSE file * or at https://opensource.org/licenses/MIT. */ import { Health, Layer } from '@mdf.js/core'; import { EventEmitter } from 'stream'; import { CommandJobDone, CommandJobHandler, Control } from '../../types'; export declare class Registry extends EventEmitter implements Layer.App.Resource { readonly name: string; private readonly maxInactivityTime; private readonly registerLimit; /** Component identification */ readonly componentId: string; /** Array of messages used as fifo register */ readonly messages: Control.Message[]; /** Processed jobs */ readonly executedJobs: CommandJobDone[]; /** Pending commands */ readonly pendingJobs: Map<string, CommandJobHandler>; /** Uncleaned jobs check internal interval */ private interval?; /** Time in milliseconds assigned to check internal */ private readonly timeInterval; /** Represent the actual status of the register of jobs */ private _status; /** * Creates a new Register instance * @param name - Component name * @param maxInactivityTime - Max time in minutes that a job could be pending state * @param registerLimit - Maximum number of entries in the message register */ constructor(name: string, maxInactivityTime?: number, registerLimit?: number); /** * Add a new job to the registry of the jobs managed by this consumer * @param job - job to be added to be added */ push(job: CommandJobHandler): void; /** * Add a new message to the registry of the last messages managed by this consumer * @param message - message to be added */ push(message: Control.Message): void; /** Perform the cleaning of all the resources */ clear(): void; /** * Return the job from the register and return it * @param uuid - Job uuid * @returns */ delete(uuid: string): CommandJobHandler | undefined; /** * Check if there are pending jobs that have been pending for too long */ private readonly checkOldPendingJobs; /** Return a resume of the pending jobs in the register */ private resume; /** Return the status of the register */ get status(): Health.Status; /** * Return the status of the stream in a standard format * @returns _check object_ as defined in the draft standard * https://datatracker.ietf.org/doc/html/draft-inadarei-api-health-check-05 */ get checks(): Health.Checks; /** Fake start method used to implement the Resource interface */ start(): Promise<void>; /** Fake stop method used to implement the Resource interface */ stop(): Promise<void>; /** Fake close method used to implement the Resource interface */ close(): Promise<void>; } //# sourceMappingURL=Registry.d.ts.map