@zilliz/milvus2-sdk-node 2.6.10 → 2.6.11-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/milvus/HttpClient.d.ts +10 -10
  2. package/dist/milvus/const/error.d.ts +1 -0
  3. package/dist/milvus/const/error.js +2 -1
  4. package/dist/milvus/const/error.js.map +1 -1
  5. package/dist/milvus/const/milvus.d.ts +3 -1
  6. package/dist/milvus/const/milvus.js +2 -0
  7. package/dist/milvus/const/milvus.js.map +1 -1
  8. package/dist/milvus/grpc/BaseClient.d.ts +7 -1
  9. package/dist/milvus/grpc/BaseClient.js +17 -2
  10. package/dist/milvus/grpc/BaseClient.js.map +1 -1
  11. package/dist/milvus/grpc/Data.d.ts +68 -4
  12. package/dist/milvus/grpc/Data.js +101 -4
  13. package/dist/milvus/grpc/Data.js.map +1 -1
  14. package/dist/milvus/grpc/GrpcClient.d.ts +19 -3
  15. package/dist/milvus/grpc/GrpcClient.js +168 -10
  16. package/dist/milvus/grpc/GrpcClient.js.map +1 -1
  17. package/dist/milvus/http/Alias.d.ts +1 -1
  18. package/dist/milvus/http/Collection.d.ts +1 -1
  19. package/dist/milvus/http/Database.d.ts +1 -1
  20. package/dist/milvus/http/Import.d.ts +1 -1
  21. package/dist/milvus/http/MilvusIndex.d.ts +1 -1
  22. package/dist/milvus/http/Partition.d.ts +1 -1
  23. package/dist/milvus/http/Role.d.ts +1 -1
  24. package/dist/milvus/http/User.d.ts +1 -1
  25. package/dist/milvus/http/Vector.d.ts +1 -1
  26. package/dist/milvus/proto-json/milvus.d.ts +56 -56
  27. package/dist/milvus/proto-json/milvus.js +56 -56
  28. package/dist/milvus/proto-json/milvus.js.map +1 -1
  29. package/dist/milvus/types/Client.d.ts +8 -3
  30. package/dist/milvus/types/Collection.d.ts +8 -0
  31. package/dist/milvus/types/GlobalCluster.d.ts +23 -0
  32. package/dist/milvus/types/GlobalCluster.js +12 -0
  33. package/dist/milvus/types/GlobalCluster.js.map +1 -0
  34. package/dist/milvus/types/Segments.d.ts +33 -1
  35. package/dist/milvus/types/index.d.ts +1 -0
  36. package/dist/milvus/types/index.js +1 -0
  37. package/dist/milvus/types/index.js.map +1 -1
  38. package/dist/milvus/utils/Function.d.ts +14 -1
  39. package/dist/milvus/utils/Function.js +51 -22
  40. package/dist/milvus/utils/Function.js.map +1 -1
  41. package/dist/milvus/utils/GlobalTopology.d.ts +56 -0
  42. package/dist/milvus/utils/GlobalTopology.js +215 -0
  43. package/dist/milvus/utils/GlobalTopology.js.map +1 -0
  44. package/dist/milvus/utils/index.d.ts +1 -0
  45. package/dist/milvus/utils/index.js +1 -0
  46. package/dist/milvus/utils/index.js.map +1 -1
  47. package/dist/sdk.json +1 -1
  48. package/package.json +10 -5
@@ -35,6 +35,7 @@ export interface ClientConfig {
35
35
  __SKIP_CONNECT__?: boolean;
36
36
  loaderOptions?: LoaderOption;
37
37
  trace?: boolean;
38
+ isGlobal?: boolean;
38
39
  }
39
40
  export interface ServerInfo {
40
41
  build_tags?: string;
@@ -47,10 +48,14 @@ export interface ServerInfo {
47
48
  };
48
49
  }
49
50
  export interface RunAnalyzerRequest {
50
- analyzer_params: Record<string, any>;
51
+ analyzer_params?: Record<string, any>;
51
52
  text: string | string[];
52
- with_detail: boolean;
53
- with_hash: boolean;
53
+ with_detail?: boolean;
54
+ with_hash?: boolean;
55
+ db_name?: string;
56
+ collection_name?: string;
57
+ field_name?: string;
58
+ analyzer_names?: string[];
54
59
  }
55
60
  type AnalyzerToken = {
56
61
  token: string;
@@ -136,6 +136,12 @@ export interface ListAliasesReq extends collectionNameReq {
136
136
  }
137
137
  export interface CompactReq extends collectionNameReq {
138
138
  timetravel?: number | string;
139
+ majorCompaction?: boolean;
140
+ partition_id?: number | string;
141
+ channel?: string;
142
+ segment_ids?: number[];
143
+ l0Compaction?: boolean;
144
+ target_size?: number | string;
139
145
  }
140
146
  export interface GetCompactionStateReq extends GrpcTimeOut {
141
147
  compactionID: number | string;
@@ -156,6 +162,7 @@ export interface BoolResponse extends resStatusResponse {
156
162
  }
157
163
  export interface CompactionResponse extends resStatusResponse {
158
164
  compactionID: string;
165
+ compactionPlanCount: number;
159
166
  }
160
167
  export interface CollectionSchema {
161
168
  name: string;
@@ -201,6 +208,7 @@ export interface GetCompactionStateResponse extends resStatusResponse {
201
208
  executingPlanNo: string;
202
209
  timeoutPlanNo: string;
203
210
  completedPlanNo: string;
211
+ failedPlanNo: string;
204
212
  }
205
213
  export interface ShowCollectionsResponse extends TimeStampArray {
206
214
  status: ResStatus;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Bitset flags for cluster capabilities.
3
+ */
4
+ export declare const ClusterCapability: {
5
+ readonly READABLE: 1;
6
+ readonly WRITABLE: 2;
7
+ readonly PRIMARY: 3;
8
+ };
9
+ /**
10
+ * Information about a cluster in the global topology.
11
+ */
12
+ export interface ClusterInfo {
13
+ clusterId: string;
14
+ endpoint: string;
15
+ capability: number;
16
+ }
17
+ /**
18
+ * Global cluster topology containing all clusters.
19
+ */
20
+ export interface GlobalTopology {
21
+ version: number;
22
+ clusters: ClusterInfo[];
23
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClusterCapability = void 0;
4
+ /**
5
+ * Bitset flags for cluster capabilities.
6
+ */
7
+ exports.ClusterCapability = {
8
+ READABLE: 0b01,
9
+ WRITABLE: 0b10,
10
+ PRIMARY: 0b11, // read + write
11
+ };
12
+ //# sourceMappingURL=GlobalCluster.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GlobalCluster.js","sourceRoot":"","sources":["../../../milvus/types/GlobalCluster.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,iBAAiB,GAAG;IAC/B,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,IAAI,EAAE,eAAe;CACtB,CAAC"}
@@ -1,7 +1,10 @@
1
1
  import { SegmentState, SegmentLevel } from '../const';
2
2
  import { resStatusResponse, collectionNameReq, GrpcTimeOut } from './Common';
3
3
  export interface GetFlushStateReq extends GrpcTimeOut {
4
- segmentIDs: number[];
4
+ segmentIDs?: number[];
5
+ flush_ts?: number;
6
+ db_name?: string;
7
+ collection_name?: string;
5
8
  }
6
9
  export interface FlushReq extends GrpcTimeOut {
7
10
  collection_names: string[];
@@ -25,6 +28,8 @@ export interface QuerySegmentInfo {
25
28
  state: SegmentState;
26
29
  nodeIds: number[];
27
30
  level: SegmentLevel;
31
+ is_sorted: boolean;
32
+ storage_version: number;
28
33
  }
29
34
  export interface GetQuerySegmentInfoResponse extends resStatusResponse {
30
35
  infos: QuerySegmentInfo[];
@@ -35,6 +40,9 @@ export interface PersistentSegmentInfo {
35
40
  partitionID: number;
36
41
  num_rows: number;
37
42
  state: SegmentState;
43
+ level: SegmentLevel;
44
+ is_sorted: boolean;
45
+ storage_version: number;
38
46
  }
39
47
  export interface GePersistentSegmentInfoResponse extends resStatusResponse {
40
48
  infos: PersistentSegmentInfo[];
@@ -53,6 +61,28 @@ export interface DescribeSegmentIndexDataResponse extends resStatusResponse {
53
61
  index_params: any;
54
62
  index_data: any;
55
63
  }
64
+ export interface FlushAllReq extends GrpcTimeOut {
65
+ db_name?: string;
66
+ }
67
+ export interface FlushClusterInfo {
68
+ cluster_id: string;
69
+ cchannel: string;
70
+ pchannels: string[];
71
+ }
72
+ export interface FlushAllResponse extends resStatusResponse {
73
+ flush_all_ts: number;
74
+ flush_all_tss: Record<string, number>;
75
+ flush_all_msgs: Record<string, any>;
76
+ cluster_info: FlushClusterInfo;
77
+ }
78
+ export interface GetFlushAllStateReq extends GrpcTimeOut {
79
+ flush_all_ts?: number;
80
+ db_name?: string;
81
+ flush_all_tss?: Record<string, number>;
82
+ }
83
+ export interface GetFlushAllStateResponse extends resStatusResponse {
84
+ flushed: boolean;
85
+ }
56
86
  export interface GetQuerySegmentInfoReq extends GrpcTimeOut {
57
87
  collectionName: string;
58
88
  dbName?: string;
@@ -65,4 +95,6 @@ export interface LoadBalanceReq extends GrpcTimeOut {
65
95
  src_nodeID: number;
66
96
  dst_nodeIDs?: number[];
67
97
  sealed_segmentIDs?: number[];
98
+ collectionName?: string;
99
+ db_name?: string;
68
100
  }
@@ -15,3 +15,4 @@ export * from './Segments';
15
15
  export * from './Insert';
16
16
  export * from './Search';
17
17
  export * from './DataTypes';
18
+ export * from './GlobalCluster';
@@ -32,4 +32,5 @@ __exportStar(require("./Segments"), exports);
32
32
  __exportStar(require("./Insert"), exports);
33
33
  __exportStar(require("./Search"), exports);
34
34
  __exportStar(require("./DataTypes"), exports);
35
+ __exportStar(require("./GlobalCluster"), exports);
35
36
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../milvus/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,eAAe;AACf,6CAA2B;AAC3B,+CAA6B;AAC7B,yCAAuB;AACvB,2CAAyB;AACzB,gDAA8B;AAC9B,8CAA4B;AAC5B,6CAA2B;AAC3B,yCAAuB;AACvB,6CAA2B;AAC3B,2CAAyB;AACzB,gDAA8B;AAC9B,8CAA4B;AAC5B,yCAAuB;AACvB,6CAA2B;AAC3B,2CAAyB;AACzB,2CAAyB;AACzB,8CAA4B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../milvus/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,eAAe;AACf,6CAA2B;AAC3B,+CAA6B;AAC7B,yCAAuB;AACvB,2CAAyB;AACzB,gDAA8B;AAC9B,8CAA4B;AAC5B,6CAA2B;AAC3B,yCAAuB;AACvB,6CAA2B;AAC3B,2CAAyB;AACzB,gDAA8B;AAC9B,8CAA4B;AAC5B,yCAAuB;AACvB,6CAA2B;AAC3B,2CAAyB;AACzB,2CAAyB;AACzB,8CAA4B;AAC5B,kDAAgC"}
@@ -1,7 +1,20 @@
1
1
  import { KeyValuePair, FieldSchema, SparseFloatVector, FieldData } from '../';
2
2
  import { Pool } from 'generic-pool';
3
3
  /**
4
- * Promisify a function call with optional timeout and metadata
4
+ * Failover handler type for global cluster support.
5
+ * When attached to a pool, promisify will call this on UNAVAILABLE errors
6
+ * after all interceptor retries are exhausted.
7
+ * Should return a new pool to retry with, or null if no failover occurred.
8
+ */
9
+ export type FailoverHandler = (error: any) => Promise<Pool<any> | null>;
10
+ /** Well-known property key for attaching a failover handler to a pool. */
11
+ export declare const FAILOVER_HANDLER_KEY = "__failoverHandler";
12
+ /**
13
+ * Attach a failover handler to a pool for global cluster support.
14
+ */
15
+ export declare function setPoolFailoverHandler(pool: Pool<any>, handler: FailoverHandler): void;
16
+ /**
17
+ * Promisify a function call with optional timeout, metadata, and global cluster failover.
5
18
  * @param pool - The pool of gRPC clients
6
19
  * @param target - The name of the target function to call
7
20
  * @param params - The parameters to pass to the target function (may contain client_request_id or client-request-id)
@@ -9,55 +9,54 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.extractRequestMetadata = exports.getValidDataArray = exports.getSparseDim = exports.getPKFieldExpr = exports.getQueryIteratorExpr = exports.sleep = exports.findKeyValue = exports.promisify = void 0;
12
+ exports.extractRequestMetadata = exports.getValidDataArray = exports.getSparseDim = exports.getPKFieldExpr = exports.getQueryIteratorExpr = exports.sleep = exports.findKeyValue = exports.promisify = exports.setPoolFailoverHandler = exports.FAILOVER_HANDLER_KEY = void 0;
13
13
  const __1 = require("../");
14
+ const logger_1 = require("./logger");
14
15
  const grpc_js_1 = require("@grpc/grpc-js");
16
+ /** Well-known property key for attaching a failover handler to a pool. */
17
+ exports.FAILOVER_HANDLER_KEY = '__failoverHandler';
15
18
  /**
16
- * Promisify a function call with optional timeout and metadata
17
- * @param pool - The pool of gRPC clients
18
- * @param target - The name of the target function to call
19
- * @param params - The parameters to pass to the target function (may contain client_request_id or client-request-id)
20
- * @param timeout - Optional timeout in milliseconds
21
- * @param requestMetadata - Optional metadata to include in the request (e.g., client-request-id). If not provided, will be extracted from params automatically.
22
- * @returns A Promise that resolves with the result of the target function call
19
+ * Attach a failover handler to a pool for global cluster support.
23
20
  */
24
- function promisify(pool, target, params, timeout, requestMetadata) {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- // Calculate the deadline for the function call
27
- const t = timeout === 0 ? 1000 * 60 * 60 * 24 : timeout;
28
- // get client
21
+ function setPoolFailoverHandler(pool, handler) {
22
+ pool[exports.FAILOVER_HANDLER_KEY] = handler;
23
+ }
24
+ exports.setPoolFailoverHandler = setPoolFailoverHandler;
25
+ /**
26
+ * Check if an error is a gRPC UNAVAILABLE error.
27
+ */
28
+ function isUnavailableError(err) {
29
+ return err && err.code === grpc_js_1.status.UNAVAILABLE;
30
+ }
31
+ /**
32
+ * Execute a single gRPC call via the pool.
33
+ */
34
+ function executeCall(pool, target, params, timeout, requestMetadata) {
35
+ const t = timeout === 0 ? 1000 * 60 * 60 * 24 : timeout;
36
+ return (() => __awaiter(this, void 0, void 0, function* () {
29
37
  const client = yield pool.acquire();
30
- // Extract traceid from params if requestMetadata is not explicitly provided
31
38
  let finalRequestMetadata = requestMetadata;
32
39
  if (!finalRequestMetadata && params) {
33
40
  finalRequestMetadata = (0, exports.extractRequestMetadata)(params);
34
41
  }
35
- // Create metadata object if traceid is found
36
42
  const metadata = finalRequestMetadata ? new grpc_js_1.Metadata() : undefined;
37
43
  if (metadata && finalRequestMetadata) {
38
- // Support both client_request_id and client-request-id (for compatibility)
39
- // Priority: client_request_id > client-request-id (JavaScript/TypeScript convention)
40
44
  const clientRequestId = getClientRequestId(finalRequestMetadata);
41
45
  if (clientRequestId) {
42
- // Convert to string to prevent runtime errors if non-string value is passed
43
46
  metadata.add(__1.METADATA.CLIENT_REQUEST_ID, String(clientRequestId));
44
47
  }
45
48
  }
46
- // Create a new Promise that wraps the target function call
47
49
  return new Promise((resolve, reject) => {
48
50
  try {
49
- // Call the target function with the provided parameters, deadline, and metadata
50
51
  const callOptions = { deadline: new Date(Date.now() + t) };
51
52
  if (metadata) {
52
53
  callOptions.metadata = metadata;
53
54
  }
54
55
  client[target](params, callOptions, (err, result) => {
55
56
  if (err) {
56
- // If there was an error, reject the Promise with the error
57
57
  reject(err);
58
58
  }
59
59
  else {
60
- // Otherwise, resolve the Promise with the result
61
60
  resolve(result);
62
61
  }
63
62
  if (client) {
@@ -72,6 +71,36 @@ function promisify(pool, target, params, timeout, requestMetadata) {
72
71
  }
73
72
  }
74
73
  });
74
+ }))();
75
+ }
76
+ /**
77
+ * Promisify a function call with optional timeout, metadata, and global cluster failover.
78
+ * @param pool - The pool of gRPC clients
79
+ * @param target - The name of the target function to call
80
+ * @param params - The parameters to pass to the target function (may contain client_request_id or client-request-id)
81
+ * @param timeout - Optional timeout in milliseconds
82
+ * @param requestMetadata - Optional metadata to include in the request (e.g., client-request-id). If not provided, will be extracted from params automatically.
83
+ * @returns A Promise that resolves with the result of the target function call
84
+ */
85
+ function promisify(pool, target, params, timeout, requestMetadata) {
86
+ return __awaiter(this, void 0, void 0, function* () {
87
+ try {
88
+ return yield executeCall(pool, target, params, timeout, requestMetadata);
89
+ }
90
+ catch (error) {
91
+ // Check for global cluster failover handler
92
+ const handler = pool[exports.FAILOVER_HANDLER_KEY];
93
+ if (handler && isUnavailableError(error)) {
94
+ logger_1.logger.debug(`\x1b[36m[Global]\x1b[0m UNAVAILABLE error on \x1b[1m${target}\x1b[0m, triggering failover handler`);
95
+ const newPool = yield handler(error);
96
+ if (newPool) {
97
+ logger_1.logger.debug(`\x1b[36m[Global]\x1b[0m Failover complete, retrying \x1b[1m${target}\x1b[0m with new pool`);
98
+ // Retry once with the new pool (after failover)
99
+ return yield executeCall(newPool, target, params, timeout, requestMetadata);
100
+ }
101
+ }
102
+ throw error;
103
+ }
75
104
  });
76
105
  }
77
106
  exports.promisify = promisify;
@@ -1 +1 @@
1
- {"version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AAS,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IACnD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAJW,QAAA,iBAAiB,qBAI5B;AAEF;;;;;GAKG;AACH,MAAM,kBAAkB,GAAG,CAAC,QAG3B,EAAsB,EAAE;IACvB,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,SAAS,CAAC;KAClB;IACD,qFAAqF;IACrF,OAAO,QAAQ,CAAC,iBAAiB,IAAI,QAAQ,CAAC,mBAAmB,CAAC,CAAC;AACrE,CAAC,CAAC;AAEF;;;;;;GAMG;AACI,MAAM,sBAAsB,GAAG,CACpC,IAAS,EAKG,EAAE;IACd,MAAM,eAAe,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACjD,OAAO,eAAe;QACpB,CAAC,CAAC,EAAE,mBAAmB,EAAE,MAAM,CAAC,eAAe,CAAC,EAAE;QAClD,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC,CAAC;AAXW,QAAA,sBAAsB,0BAWjC"}
@@ -0,0 +1,56 @@
1
+ import { ClusterCapability, ClusterInfo, GlobalTopology } from '../types/GlobalCluster';
2
+ export { ClusterCapability, ClusterInfo, GlobalTopology };
3
+ export declare const GLOBAL_CLUSTER_IDENTIFIER = "global-cluster";
4
+ export declare const DEFAULT_REFRESH_INTERVAL = 300000;
5
+ /**
6
+ * Check if a ClusterInfo is the primary (writable) cluster.
7
+ */
8
+ export declare function isPrimaryCluster(cluster: ClusterInfo): boolean;
9
+ /**
10
+ * Get the primary cluster from a topology.
11
+ * @throws Error if no primary cluster is found.
12
+ */
13
+ export declare function getPrimaryCluster(topology: GlobalTopology): ClusterInfo;
14
+ /**
15
+ * Check if the URI points to a global cluster endpoint.
16
+ */
17
+ export declare function isGlobalEndpoint(uri: string): boolean;
18
+ /**
19
+ * Fetch the global cluster topology from the REST API.
20
+ *
21
+ * @param globalEndpoint - The global cluster endpoint URL
22
+ * @param token - Authentication token
23
+ * @returns GlobalTopology object containing cluster information
24
+ * @throws Error if topology cannot be fetched after retries
25
+ */
26
+ export declare function fetchTopology(globalEndpoint: string, token: string): Promise<GlobalTopology>;
27
+ /**
28
+ * Background refresher that periodically fetches the global cluster topology.
29
+ */
30
+ export declare class TopologyRefresher {
31
+ private globalEndpoint;
32
+ private token;
33
+ private topology;
34
+ private refreshInterval;
35
+ private onTopologyChange?;
36
+ private intervalId;
37
+ private refreshing;
38
+ constructor(options: {
39
+ globalEndpoint: string;
40
+ token: string;
41
+ topology: GlobalTopology;
42
+ refreshInterval?: number;
43
+ onTopologyChange?: (topology: GlobalTopology) => void;
44
+ });
45
+ /** Start the background refresh interval. */
46
+ start(): void;
47
+ /** Stop the background refresh interval. */
48
+ stop(): void;
49
+ /** Check if the refresher is running. */
50
+ isRunning(): boolean;
51
+ /** Get the current topology. */
52
+ getTopology(): GlobalTopology;
53
+ /** Trigger an immediate topology refresh (debounced). */
54
+ triggerRefresh(): void;
55
+ private tryRefresh;
56
+ }
@@ -0,0 +1,215 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.TopologyRefresher = exports.fetchTopology = exports.isGlobalEndpoint = exports.getPrimaryCluster = exports.isPrimaryCluster = exports.DEFAULT_REFRESH_INTERVAL = exports.GLOBAL_CLUSTER_IDENTIFIER = exports.ClusterCapability = void 0;
13
+ const logger_1 = require("./logger");
14
+ const GlobalCluster_1 = require("../types/GlobalCluster");
15
+ Object.defineProperty(exports, "ClusterCapability", { enumerable: true, get: function () { return GlobalCluster_1.ClusterCapability; } });
16
+ // Identifier used in URIs to detect global cluster endpoints
17
+ exports.GLOBAL_CLUSTER_IDENTIFIER = 'global-cluster';
18
+ // Retry constants for topology fetch
19
+ const MAX_RETRIES = 3;
20
+ const BASE_DELAY = 1000; // ms
21
+ const MAX_DELAY = 10000; // ms
22
+ const REQUEST_TIMEOUT = 10000; // ms
23
+ // Default refresh interval for topology refresher
24
+ exports.DEFAULT_REFRESH_INTERVAL = 300000; // 5 minutes in ms
25
+ /**
26
+ * Check if a ClusterInfo is the primary (writable) cluster.
27
+ */
28
+ function isPrimaryCluster(cluster) {
29
+ return (cluster.capability & GlobalCluster_1.ClusterCapability.WRITABLE) !== 0;
30
+ }
31
+ exports.isPrimaryCluster = isPrimaryCluster;
32
+ /**
33
+ * Get the primary cluster from a topology.
34
+ * @throws Error if no primary cluster is found.
35
+ */
36
+ function getPrimaryCluster(topology) {
37
+ const primary = topology.clusters.find(isPrimaryCluster);
38
+ if (!primary) {
39
+ throw new Error('No primary cluster found in topology');
40
+ }
41
+ return primary;
42
+ }
43
+ exports.getPrimaryCluster = getPrimaryCluster;
44
+ /**
45
+ * Check if the URI points to a global cluster endpoint.
46
+ */
47
+ function isGlobalEndpoint(uri) {
48
+ if (!uri)
49
+ return false;
50
+ return uri.toLowerCase().includes(exports.GLOBAL_CLUSTER_IDENTIFIER);
51
+ }
52
+ exports.isGlobalEndpoint = isGlobalEndpoint;
53
+ /**
54
+ * Parse the topology response from the REST API.
55
+ */
56
+ function parseTopologyResponse(data) {
57
+ return {
58
+ version: parseInt(data.version, 10),
59
+ clusters: data.clusters.map(c => ({
60
+ clusterId: c.clusterId,
61
+ endpoint: c.endpoint,
62
+ capability: c.capability,
63
+ })),
64
+ };
65
+ }
66
+ /**
67
+ * Fetch the global cluster topology from the REST API.
68
+ *
69
+ * @param globalEndpoint - The global cluster endpoint URL
70
+ * @param token - Authentication token
71
+ * @returns GlobalTopology object containing cluster information
72
+ * @throws Error if topology cannot be fetched after retries
73
+ */
74
+ function fetchTopology(globalEndpoint, token) {
75
+ var _a, _b;
76
+ return __awaiter(this, void 0, void 0, function* () {
77
+ // Build the topology URL
78
+ let endpoint = globalEndpoint.replace(/\/+$/, '');
79
+ if (!endpoint.startsWith('http://') && !endpoint.startsWith('https://')) {
80
+ endpoint = `https://${endpoint}`;
81
+ }
82
+ const url = `${endpoint}/${exports.GLOBAL_CLUSTER_IDENTIFIER}/topology`;
83
+ const headers = {
84
+ Authorization: `Bearer ${token}`,
85
+ };
86
+ logger_1.logger.debug(`\x1b[36m[Global]\x1b[0m Fetching topology from ${url}`);
87
+ let lastError = null;
88
+ for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
89
+ try {
90
+ const controller = new AbortController();
91
+ const timeoutId = setTimeout(() => controller.abort(), REQUEST_TIMEOUT);
92
+ const response = yield fetch(url, {
93
+ headers,
94
+ signal: controller.signal,
95
+ });
96
+ clearTimeout(timeoutId);
97
+ if (!response.ok) {
98
+ const text = yield response.text();
99
+ const err = new Error(`Topology request failed with status ${response.status}: ${text}`);
100
+ // Only retry on 5xx server errors; 4xx are permanent (auth, bad request, etc.)
101
+ if (response.status >= 400 && response.status < 500) {
102
+ logger_1.logger.debug(`\x1b[36m[Global]\x1b[0m Topology fetch failed with ${response.status} (not retryable)`);
103
+ throw err;
104
+ }
105
+ throw Object.assign(err, { retryable: true });
106
+ }
107
+ const result = yield response.json();
108
+ if (result.code !== undefined && result.code !== 0) {
109
+ // API-level error, don't retry
110
+ logger_1.logger.debug(`\x1b[36m[Global]\x1b[0m Topology API error code=${result.code}: ${result.message}`);
111
+ throw new Error(result.message || 'Unknown API error');
112
+ }
113
+ const topology = parseTopologyResponse(result.data);
114
+ logger_1.logger.debug(`\x1b[36m[Global]\x1b[0m Topology fetched: version=${topology.version}, clusters=${topology.clusters.length}, primary=${((_a = topology.clusters.find(c => isPrimaryCluster(c))) === null || _a === void 0 ? void 0 : _a.endpoint) || 'none'}`);
115
+ return topology;
116
+ }
117
+ catch (e) {
118
+ // Only retry network errors, timeouts, and 5xx errors
119
+ if (!e.retryable && e.name !== 'AbortError' && !((_b = e.message) === null || _b === void 0 ? void 0 : _b.includes('fetch failed'))) {
120
+ throw e;
121
+ }
122
+ lastError = e;
123
+ if (attempt < MAX_RETRIES - 1) {
124
+ const delay = Math.min(BASE_DELAY * Math.pow(2, attempt), MAX_DELAY);
125
+ const jitter = delay * 0.1 * Math.random();
126
+ logger_1.logger.warn(`Topology fetch attempt ${attempt + 1} failed: ${e.message}. Retrying in ${(delay + jitter).toFixed(0)}ms`);
127
+ yield new Promise(resolve => setTimeout(resolve, delay + jitter));
128
+ }
129
+ }
130
+ }
131
+ throw new Error(`Failed to fetch global topology after ${MAX_RETRIES} attempts: ${lastError === null || lastError === void 0 ? void 0 : lastError.message}`);
132
+ });
133
+ }
134
+ exports.fetchTopology = fetchTopology;
135
+ /**
136
+ * Background refresher that periodically fetches the global cluster topology.
137
+ */
138
+ class TopologyRefresher {
139
+ constructor(options) {
140
+ var _a;
141
+ this.intervalId = null;
142
+ this.refreshing = false;
143
+ this.globalEndpoint = options.globalEndpoint;
144
+ this.token = options.token;
145
+ this.topology = options.topology;
146
+ this.refreshInterval =
147
+ (_a = options.refreshInterval) !== null && _a !== void 0 ? _a : exports.DEFAULT_REFRESH_INTERVAL;
148
+ this.onTopologyChange = options.onTopologyChange;
149
+ }
150
+ /** Start the background refresh interval. */
151
+ start() {
152
+ if (this.intervalId !== null)
153
+ return;
154
+ logger_1.logger.debug(`\x1b[36m[Global]\x1b[0m TopologyRefresher started, interval=${this.refreshInterval}ms`);
155
+ this.intervalId = setInterval(() => this.tryRefresh(), this.refreshInterval);
156
+ // Allow the Node.js process to exit even if the interval is still running
157
+ if (this.intervalId && typeof this.intervalId === 'object' && 'unref' in this.intervalId) {
158
+ this.intervalId.unref();
159
+ }
160
+ }
161
+ /** Stop the background refresh interval. */
162
+ stop() {
163
+ if (this.intervalId !== null) {
164
+ clearInterval(this.intervalId);
165
+ this.intervalId = null;
166
+ logger_1.logger.debug(`\x1b[36m[Global]\x1b[0m TopologyRefresher stopped`);
167
+ }
168
+ }
169
+ /** Check if the refresher is running. */
170
+ isRunning() {
171
+ return this.intervalId !== null;
172
+ }
173
+ /** Get the current topology. */
174
+ getTopology() {
175
+ return this.topology;
176
+ }
177
+ /** Trigger an immediate topology refresh (debounced). */
178
+ triggerRefresh() {
179
+ if (this.refreshing) {
180
+ logger_1.logger.debug(`\x1b[36m[Global]\x1b[0m Topology refresh already in progress, skipping`);
181
+ return;
182
+ }
183
+ logger_1.logger.debug(`\x1b[36m[Global]\x1b[0m Triggering immediate topology refresh`);
184
+ this.refreshing = true;
185
+ this.tryRefresh().finally(() => {
186
+ this.refreshing = false;
187
+ });
188
+ }
189
+ tryRefresh() {
190
+ return __awaiter(this, void 0, void 0, function* () {
191
+ try {
192
+ const newTopology = yield fetchTopology(this.globalEndpoint, this.token);
193
+ if (newTopology.version > this.topology.version) {
194
+ const oldVersion = this.topology.version;
195
+ this.topology = newTopology;
196
+ logger_1.logger.info(`Topology updated: version ${oldVersion} -> ${newTopology.version}`);
197
+ if (this.onTopologyChange) {
198
+ try {
199
+ this.onTopologyChange(newTopology);
200
+ }
201
+ catch (_a) {
202
+ logger_1.logger.warn('Topology change callback failed');
203
+ }
204
+ }
205
+ }
206
+ }
207
+ catch (_b) {
208
+ logger_1.logger.warn('Topology refresh failed');
209
+ // Keep using cached topology, will retry next interval
210
+ }
211
+ });
212
+ }
213
+ }
214
+ exports.TopologyRefresher = TopologyRefresher;
215
+ //# sourceMappingURL=GlobalTopology.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GlobalTopology.js","sourceRoot":"","sources":["../../../milvus/utils/GlobalTopology.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAkC;AAClC,0DAIgC;AAGvB,kGANP,iCAAiB,OAMO;AAE1B,6DAA6D;AAChD,QAAA,yBA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,CACX,CAAC;gBAEF,IAAI,WAAW,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;oBAC/C,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;oBACzC,IAAI,CAAC,QAAQ,GAAG,WAAW,CAAC;oBAC5B,eAAM,CAAC,IAAI,CACT,6BAA6B,UAAU,OAAO,WAAW,CAAC,OAAO,EAAE,CACpE,CAAC;oBAEF,IAAI,IAAI,CAAC,gBAAgB,EAAE;wBACzB,IAAI;4BACF,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;yBACpC;wBAAC,WAAM;4BACN,eAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;yBAChD;qBACF;iBACF;aACF;YAAC,WAAM;gBACN,eAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;gBACvC,uDAAuD;aACxD;QACH,CAAC;KAAA;CACF;AA1GD,8CA0GC"}
@@ -8,3 +8,4 @@ export * from './Format';
8
8
  export * from './Validate';
9
9
  export * from './Function';
10
10
  export * from './logger';
11
+ export * from './GlobalTopology';
@@ -24,4 +24,5 @@ __exportStar(require("./Format"), exports);
24
24
  __exportStar(require("./Validate"), exports);
25
25
  __exportStar(require("./Function"), exports);
26
26
  __exportStar(require("./logger"), exports);
27
+ __exportStar(require("./GlobalTopology"), exports);
27
28
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../milvus/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,+CAA6B;AAC7B,2CAAyB;AACzB,yCAAuB;AACvB,2CAAyB;AACzB,0CAAwB;AACxB,2CAAyB;AACzB,6CAA2B;AAC3B,6CAA2B;AAC3B,2CAAyB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../milvus/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,+CAA6B;AAC7B,2CAAyB;AACzB,yCAAuB;AACvB,2CAAyB;AACzB,0CAAwB;AACxB,2CAAyB;AACzB,6CAA2B;AAC3B,6CAA2B;AAC3B,2CAAyB;AACzB,mDAAiC"}
package/dist/sdk.json CHANGED
@@ -1 +1 @@
1
- {"version":"2.6.10","milvusVersion":"v2.6.9"}
1
+ {"version":"2.6.11-beta.0","milvusVersion":"v2.6.11"}