ravendb
Version:
RavenDB client for Node.js
47 lines • 1.49 kB
JavaScript
import { RavenCommand } from "../../Http/RavenCommand.js";
import { ClusterTopology } from "../../Http/ClusterTopology.js";
import { ObjectUtil } from "../../Utility/ObjectUtil.js";
export class ClusterTopologyResponse {
leader;
nodeTag;
serverRole;
topology;
etag;
status;
}
export class GetClusterTopologyCommand extends RavenCommand {
_debugTag;
constructor(debugTag) {
super();
this._debugTag = debugTag;
}
createRequest(node) {
let uri = node.url + "/cluster/topology";
if (this._debugTag) {
uri += "?" + this._debugTag;
}
return { uri };
}
async setResponseAsync(bodyStream, fromCache) {
if (!bodyStream) {
this._throwInvalidResponse();
}
let body = null;
const result = await this._pipeline()
.collectBody(b => body = b)
.parseJsonSync()
.objectKeysTransform({
defaultTransform: ObjectUtil.camel,
ignorePaths: [/topology\.(members|promotables|watchers|allNodes)\./i]
})
.process(bodyStream);
const clusterTpl = Object.assign(new ClusterTopology(), result.topology);
this.result = Object.assign(result, { topology: clusterTpl });
this.result.status = new Map(Object.entries(this.result.status));
return body;
}
get isReadRequest() {
return true;
}
}
//# sourceMappingURL=GetClusterTopologyCommand.js.map