@litert/televoke
Version:
A simple RPC service framework.
90 lines • 2.69 kB
TypeScript
/**
* Copyright 2025 Angus.Fenying <fenying@litert.org>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as $Http from 'http';
import * as $Https from 'https';
import type * as C from '../../client/Client.decl';
import * as Shared from '../../shared';
export interface ILegacyHttpClient<T extends Shared.IObject> extends C.IClient<T> {
/**
* Setup the headers for the every HTTP request.
*
* @param newHeaders The new headers to set.
* @param append Whether to append the new headers to existing headers, or replace all headers. [Default: true]
*/
setHeaders(newHeaders: $Http.OutgoingHttpHeaders, append?: boolean): void;
}
interface IHttpClientOptionsBase extends $Https.RequestOptions {
/**
* Whether to use HTTPS.
*
* @default false
*/
https?: boolean;
/**
* Wrap the API name before sending to server.
*
* @default null
*/
apiNameWrapper?: (name: string) => string;
/**
* Whether to retry on connection reset.
*
* @default true
*/
retryOnConnReset?: boolean;
/**
* The maximum number of connections.
*
* @default 100
*/
maxConnections?: number;
/**
* The timeout of keep-alive.
*
* @default 30000
*/
keepAliveTimeout?: number;
/**
* Whether to keep-alive.
*
* @default true
*/
keepAlive?: boolean;
}
export interface IHttpClientNetworkOptions extends IHttpClientOptionsBase {
/**
* The hostname of HTTP server.
*
* @default 'localhost'
*/
hostname: string;
/**
* The port of HTTP server.
*
* @default 80 or 443
*/
port?: number;
}
export interface IHttpClientUnixSocketOptions extends IHttpClientOptionsBase {
/**
* The path of Unix domain socket to connect to.
*/
socketPath: string;
}
export type IHttpClientOptions = IHttpClientNetworkOptions | IHttpClientUnixSocketOptions;
export declare function createLegacyHttpClient<TAPIs extends Shared.IObject>(opts: IHttpClientOptions): ILegacyHttpClient<TAPIs>;
export {};
//# sourceMappingURL=LegacyHttp.Client.Native.d.ts.map