import { Options, Logger } from '../types/interfaces';
import { Request } from '../request/request';
import { Response } from '../response/response';
import { AsyncArray } from '../utils/asyncArray';
import { Dependency } from '../health/health';
export declare type CallbackRequestFunction<T = any> = (d: Response<T>) => any;
export declare type CallbackHandleFunction<T = any> = (req: Request, cb?: (res?: Response<T>) => any) => Promise<Response<T>> | void;
export declare function uniqueName(name: string, uniqueID: string): string;
/**
 * Provides an interface to create your service and register request handlers.
 */
export declare class Service {
    name: string;
    protected options: Options;
    id: string;
    logger: Logger;
    private _codec;
    private _transport;
    private _tracer;
    private _healthChecks;
    private _watchdogServiceName;
    private _enableStatusEndpoints;
    private _registerToWatchdog;
    /**
     * Create new service.
     */
    constructor(name: string, options?: Options);
    private commsWithWatchdog;
    private listenToHealthChecks;
    private handleHealthCheck;
    private checkHealthOrTimeout;
    /**
     * Subscribe to a topic.
     * @param {string} topic
     * @param {Function} callback
     * @param {boolean} disableGroup
     */
    on(topic: string, callback: Function, disableGroup?: boolean): any;
    /**
     * Subscribe to a topic, getting a producer/consumer array of promises.
     * @param {string} topic
     * @param {boolean} disableGroup
     * @returns An async array following the producer/consumer pattern.
     */
    onAsync<T = any>(topic: string, disableGroup?: boolean): AsyncArray<T>;
    /**
     * Register request handler method with enabled logging.
     * @param {string} method
     * @param {Function} callback
     * @param {string} [prefix]
     */
    handle<T = any>(path: string, callback: CallbackHandleFunction<T>, prefix?: string): void;
    /**
     * Register request handler method with disabled logging.
     * @param {string} method
     * @param {Function} callback
     * @param {string} [prefix]
     */
    handleWithoutLogging<T = any>(path: string, callback: CallbackHandleFunction<T>, prefix?: string): void;
    /**
     * Start listenning on the underlying transport connection.
     * @param {Function} callback
     * @returns {Promise} returns promise if called with no callback.
     */
    listen(callback?: Function): Promise<any>;
    /**
     * Close underlying transport connection.
     */
    close(): void;
    /**
     * Connection closed handler
     * @param {Function} callback
     */
    onClose(callback: any): void;
    /**
     * Service name and id.
     */
    toString(): string;
    /**
     * Publish to a topic.
     * @param {any} topic
     * @param {Object} message
     */
    emit(topic: string, message: any): void;
    registerHealthCheck(check: Dependency): void;
    /**
     * Call service method.
     * @param {Request} request
     * @param {Object} [params]
     * @param {Function} callback
     * @returns {Promise} returns promise if called with no callback.
     */
    call<T = any>(req: Request, callback?: CallbackRequestFunction<T>): Promise<Response<T>>;
    private _getCallTimeout;
    private _call;
    private _handle;
    private _serializeRequest;
    private _checkResponse;
}
