@ultipa-graph/ultipa-node-sdk
Version:
NodeJS SDK for ultipa-server 4.0
153 lines (152 loc) • 5.83 kB
TypeScript
/// <reference types="node" />
import * as grpc from "@grpc/grpc-js";
import { ULTIPA, RequestType } from "../../types";
import { UQLMAKER, ResponseKeyFormat } from "../../utils";
declare class GrpcClientInfo {
host: string;
username: string;
password: string;
crt: Buffer;
constructor(host: string, username: string, password: string, crt?: Buffer);
getMetadata(graphSetName: string, clusterId: string, timeZone: string, timeZoneOffset: number): grpc.Metadata;
getClient(): import("../network.manager").UltipaClientAio;
}
export declare const RAFT_GLOBAL = "global";
declare class HostManagerControl {
initHost: string;
private username;
private password;
private crt;
consistency: boolean;
allHostManager: {
[x: string]: HostManager;
};
constructor(initHost: string, username: string, password: string, crt?: Buffer, consistency?: boolean);
chooseClientInfo(params?: {
type?: ULTIPA.ClientType;
uql?: string;
graphSetName: string;
useHost?: string;
useMaster?: boolean;
}): GrpcClientInfo;
upsetHostManger(graphSetName: string, initHost: string): HostManager;
getHostManger(graphSetName: string): HostManager;
getAllHosts(): string[];
closeAll(): void;
}
declare class HostManager {
graphSetName: string;
leaderHost: string;
followersPeerInfos: ULTIPA.RaftPeerInfo[];
leaderClientInfo: GrpcClientInfo;
algoClientInfos: GrpcClientInfo[];
defaultClientInfo: GrpcClientInfo;
otherFollowerClientInfos: GrpcClientInfo[];
otherUnsetFollowerClientInfos: GrpcClientInfo[];
nullClientInfos: GrpcClientInfo;
raftReady: boolean;
private username;
private password;
private crt;
constructor(graphSetName: string, host: string, username: string, password: string, crt?: Buffer);
createClientInfo(host: string): GrpcClientInfo;
getAllHosts(): string[];
chooseClientInfo(params?: {
type?: ULTIPA.ClientType;
uql?: string;
consistency?: boolean;
useHost?: string;
useMaster?: boolean;
}): GrpcClientInfo;
_chooseClientInfo(params?: {
type?: ULTIPA.ClientType;
uql?: string;
consistency?: boolean;
useHost?: string;
useMaster?: boolean;
}): GrpcClientInfo;
getAllClientInfos(p?: {
ignoreAlgo?: boolean;
needUnset?: boolean;
}): GrpcClientInfo[];
closeAll(): void;
setClients(leaderHost: string, followersPeerInfos: ULTIPA.RaftPeerInfo[]): void;
}
export declare class ConnectionBase {
hostManagerControl: HostManagerControl;
protected username: string;
protected password: string;
protected crt: Buffer;
defaultConfig: ULTIPA.UltipaConfig;
constructor(host: string, username: string, password: string, crt?: Buffer, defaultConfig?: ULTIPA.UltipaConfig, isMd5?: boolean);
setDefaultConfig(config?: ULTIPA.UltipaConfig): void;
protected getGraphSetName(currentGraphName: string, uql?: string, isGlobal?: boolean): string;
protected getTimeout(timeout: number): number;
protected getThreadNum(threadNum: number): number;
protected getLogUql(logUql: boolean): boolean;
protected getTimeZone(timeZone: string): string;
protected getTimeZoneOffset(timeZoneOffset: number): number;
protected getTimestampToString(timestampToString: boolean): boolean;
protected getClientInfo(params: {
type?: ULTIPA.ClientType;
graphSetName?: string;
uql?: string;
isGlobal?: boolean;
ignoreRaft?: boolean;
useHost?: string;
clusterId?: string;
useMaster?: boolean;
forceRefresh?: boolean;
timeZone: string;
timeZoneOffset: number;
}): Promise<{
client: import("../network.manager").UltipaClientAio;
host: string;
metadata: grpc.Metadata;
goGraphName: string;
}>;
protected getTimeZoneType(commonReq?: RequestType.RequestConfig): ULTIPA.TimeZone;
uqlStream(uql: string, stream: RequestType.UqlResponseStream, requestConfig?: RequestType.RequestConfig): Promise<void>;
uql(uql: string, requestConfig?: RequestType.RequestConfig): Promise<ULTIPA.UQLResponse>;
/**
* 运行UQL
*/
private _uql_without_catch;
/**
* 通过UQLMaker运行uql
*/
uqlSingle(uqlMaker: UQLMAKER): Promise<ULTIPA.UQLSingleResponse>;
auth(req: RequestType.Auth, commonReq?: RequestType.RequestConfig): Promise<ULTIPA.Response<any>>;
/**
* 得到集群Leader信息
*/
getRaftLeader(commonReq?: RequestType.RequestConfig): Promise<ULTIPA.Response<any>>;
/**
* 根据指定host刷新集群leader信息
* @param redirectHost 重跳host
*/
refreshRaftLeader(redirectHost?: string, commonReq?: RequestType.RequestConfig): Promise<boolean>;
/**
* 登录
*/
login(commonReq?: RequestType.RequestConfig): Promise<boolean>;
/**
* 测试连接
*/
test(commonReq?: RequestType.RequestConfig): Promise<boolean>;
/**
* 测试连接
*/
test_has_message(commonReq?: RequestType.RequestConfig): Promise<{
connect: boolean;
msg: string;
}>;
protected static UqlUpdateSimple(conn: ConnectionBase, uqlMaker: UQLMAKER): Promise<ULTIPA.Response<null>>;
protected static UqlListSimple<T>(conn: ConnectionBase, uqlMaker: UQLMAKER, keyFormat?: ResponseKeyFormat): Promise<ULTIPA.Response<T[]>>;
protected static UqlListSimpleAuto<T>(conn: ConnectionBase, uqlMaker: UQLMAKER, keyFormat?: ResponseKeyFormat): Promise<ULTIPA.Response<{
name: string;
values: T[];
}[]>>;
protected static UqlGetSimple<T>(conn: ConnectionBase, uqlMaker: UQLMAKER, keyFormat?: ResponseKeyFormat): Promise<ULTIPA.Response<T>>;
}
export {};