import ServiceChannelTap from "./service.channel.tap"; export default class Service { private serviceName; /** * Holds a private table of service channels */ private $channels; /** * Creates a service * * @param name The name of the serve */ constructor(serviceName: string); /** * Allocates a channel * * If the channel does not exist, it is created * and returned * * @param channel */ private allocate; /** * Gets the name of the service */ name(): string; /** * Returns a list of the service channel names */ channels(): string[]; /** * Get all tap instances for the a channel * * @param channel The name of the channel */ taps(channel: string): ServiceChannelTap[]; /** * Remove a route tap from a channel where the handler * shares a reference with the handler provided * * @param channel The name of the channel * @param handler The handler for the tap to remove */ removeTap(channel: string | symbol, handler: (...args: any[]) => any): void; /** * Remove all route taps for a channel * * @param channel The name of the channel */ removeAllTaps(channel: string | symbol): void; /** * Make a request to a service channel * * @param channel The name of the channel * @param args The data to be passed to the channel handler */ request(channel: string | symbol, ...args: any[]): Promise; /** * Remove a channel * * @param channel The name of the channel */ remove(channel: string | symbol): void; /** * Declare route to direct all traffic from a particular * channel to a specific handler * * @param channel The name of the channel * @param handler The handler that will handle the request * @param context The context for the handler */ route(channel: string | symbol, handler: (...args: any[]) => any, context?: any): () => void; /** * Declare route to direct all traffic from a particular * channel to a specific handler that is locked and can * not be overriden. The route can only be destroyed by * the destroyer function that is returned * * @param channel The name of the channel * @param handler The handler that will handle the request * @param context The context for the handler */ routeLock(channel: string | symbol, handler: (...args: any[]) => any, context?: any): () => void; /** * Declare route to direct all traffic from a particular * channel to a specific handler that is locked and is secure * disallowing any taps from listening to request being made * * @param channel The name of the channel * @param handler The handler that will handle the request * @param context The context for the handler */ routeLockSec(channel: string | symbol, handler: (...args: any[]) => any, context?: any): () => void; /** * Declare route tap to listens to each request made to * the main route but can not respond, nor can see the * response * * @param channel The name of the channel * @param handler The handler that will handle the request * @param context The context for the handler */ routeTap(channel: string, handler: (...args: any[]) => any, context?: any): void; /** * Helper method to throw the locked exception * * @param channel The name of the channel */ private throwLocked; }