import { Codec } from './Codec'; import { SendDataFunction } from './SendDataFunction'; /** * A bidirectional manager for Acknowledgement messages * An ACK is an special message that is provided by other process to indicate an specific status * @template T - ArgsDTO * @template U - ResolverData * @template V - Token */ export declare abstract class Ack { private readonly codec; private readonly sendData; protected abstract token: V; private interfaceIndex; constructor(codec: Codec, sendData: SendDataFunction); /** * Uses args to make a choice (resolve or reject ack promise using its interface) */ protected abstract makeChoice(args: T, ackInterface: AckInterface): void; /** * Verify if the provided data has the strcuture to be shared by the instance */ checkData(data: string): data is EncodedData; /** * Creates an ACK promise (resolved by another process) * @param id - Used to identify the ACK message * (supporting multiple messages at the same time). * This must be sended by any way to the other process, * to be sended back with the ack completion (like a calback) */ activate(id: number): Promise; /** * Reestructures the message data and resolves its ACK (data received by another process) */ receive(encodedData: EncodedData): void; /** * Send the Ack to another process, it only should be received for a manager with the same structure of that (bidirectional) */ send(args: T): void; } type EncodedData = `${T}${string}`; interface Args { id: number; } /** * Represents the setter for the final status of the message */ export interface AckInterface { resolve(data: T): void; reject(err: Error): void; } export {};