UNPKG

@mdf.js/openc2-core

Version:

MMS - API Core - OpenC2

93 lines 3.71 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 { Crash } from '@mdf.js/crash'; import EventEmitter from 'events'; import { Control } from '../../types'; export declare interface ConsumerMap { /** Emitted when a producer's operation has some problem */ on(event: 'error', listener: (error: Crash | Error) => void): this; /** Emitted on every state change */ on(event: 'status', listener: (status: Health.Status) => void): this; /** Emitted when new nodes are included included map */ on(event: 'new', listener: (nodes: string[]) => void): this; /** Emitted when some nodes has been aged */ on(event: 'aged', listener: (nodes: string[]) => void): this; /** Emitted when nodes are updated */ on(event: 'update', listener: (nodes: string[]) => void): this; /** Emitted when the consumer has been updated */ on(event: 'updated', listener: (nodes: string[]) => void): this; } export declare class ConsumerMap extends EventEmitter implements Layer.App.Resource { readonly name: string; private readonly agingInterval; private readonly maxAge; /** Flag to indicate that an unhealthy status has been emitted recently */ private lastStatusEmitted?; /** Component identification */ readonly componentId: string; /** Consumer Map */ private readonly map; /** Aging timer */ private agingTimer?; /** * Create a new instance of the consumer map * @param name - name of the producer * @param agingInterval - agingInterval to update the consumer map * @param maxAge - Max allowed age in in milliseconds for a table entry */ constructor(name: string, agingInterval: number, maxAge: number); /** Get the actual nodes */ get nodes(): Control.Response[]; /** * Returns the grouped features of all the consumer in the map * @returns */ getGroupedFeatures(): { pairs: Control.ActionTargetPairs; profiles: string[]; }; /** * Return the consumers identifiers that has the indicated action/target pair * @param action - action to search * @param target - target requested */ getConsumersWithPair(action: string, target: string): string[]; /** * Perform the update of the health map * @param responses - responses to update the consumer map */ update(responses: Control.ResponseMessage[]): void; /** * Get one node from the map * @param consumerId - consumer id to get the status * @returns */ getNode(consumerId: string): Health.Check<Control.Response> | undefined; /** Return the state of all the underlying consumers */ get checks(): Health.Checks<Control.Response>; /** Perform the aging of the consumer map */ private readonly aging; /** * Update the consumer map with a new response * @param response - response to update the consumer map */ private updateEntry; /** Overall component status */ get status(): Health.Status; /** Emit the status if it's different from the last emitted status */ private emitStatus; /** Clean the nodes map */ clear(): void; /** 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=ConsumerMap.d.ts.map