Skip to content

Commit 5bfee25

Browse files
committed
Add db.serverStatus
Fixes #811.
1 parent 58dfdcc commit 5bfee25

File tree

2 files changed

+181
-0
lines changed

2 files changed

+181
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ This driver uses semantic versioning:
7070

7171
### Added
7272

73+
- Added `database.serverStatus` method ([#811](https://github.com/arangodb/arangojs/issues/811))
74+
75+
This method fetches information about the server status.
76+
7377
- Added `onError` option to `Config` (DE-955)
7478

7579
This option can be used to specify a callback function that will be invoked

src/database.ts

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,164 @@ export type DatabaseInfo = {
930930
writeConcern?: number;
931931
};
932932

933+
/**
934+
* Information about the server status.
935+
*/
936+
export type ServerStatusInformation = {
937+
/**
938+
* (Cluster Coordinators and DB-Servers only.) The address of the server.
939+
*/
940+
address?: string;
941+
/**
942+
* (Cluster Coordinators and DB-Servers only.) Information about the Agency.
943+
*/
944+
agency?: {
945+
/**
946+
* Information about the communication with the Agency.
947+
*/
948+
agencyComm: {
949+
/**
950+
* A list of possible Agency endpoints.
951+
*/
952+
endpoints: string[];
953+
};
954+
};
955+
/**
956+
* (Cluster Agents only.) Information about the Agents.
957+
*/
958+
agent?: {
959+
/**
960+
* The endpoint of the queried Agent.
961+
*/
962+
endpoint: string;
963+
/**
964+
* Server ID of the queried Agent.
965+
*/
966+
id: string;
967+
/**
968+
* Server ID of the leading Agent.
969+
*/
970+
leaderId: string;
971+
/**
972+
* Whether the queried Agent is the leader.
973+
*/
974+
leading: boolean;
975+
/**
976+
* The current term number.
977+
*/
978+
term: number;
979+
};
980+
/**
981+
* (Cluster Coordinators only.) Information about the Coordinators.
982+
*/
983+
coordinator?: {
984+
/**
985+
* The server ID of the Coordinator that is the Foxx master.
986+
*/
987+
foxxmaster: string[];
988+
/**
989+
* Whether the queried Coordinator is the Foxx master.
990+
*/
991+
isFoxxmaster: boolean[];
992+
};
993+
/**
994+
* Whether the Foxx API is enabled.
995+
*/
996+
foxxApi: boolean;
997+
/**
998+
* A host identifier defined by the HOST or NODE_NAME environment variable,
999+
* or a fallback value using a machine identifier or the cluster/Agency address.
1000+
*/
1001+
host: string;
1002+
/**
1003+
* A hostname defined by the HOSTNAME environment variable.
1004+
*/
1005+
hostname?: string;
1006+
/**
1007+
* ArangoDB Edition.
1008+
*/
1009+
license: "community" | "enterprise";
1010+
/**
1011+
* Server operation mode.
1012+
*
1013+
* @deprecated use `operationMode` instead
1014+
*/
1015+
mode: "server" | "console";
1016+
/**
1017+
* Server operation mode.
1018+
*/
1019+
operationMode: "server" | "console";
1020+
/**
1021+
* The process ID of arangod.
1022+
*/
1023+
pid: number;
1024+
/**
1025+
* Server type.
1026+
*/
1027+
server: "arango";
1028+
/**
1029+
* Information about the server status.
1030+
*/
1031+
serverInfo: {
1032+
/**
1033+
* Whether the maintenance mode is enabled.
1034+
*/
1035+
maintenance: boolean;
1036+
/**
1037+
* (Cluster only.) The persisted ID.
1038+
*/
1039+
persistedId?: string;
1040+
/**
1041+
* Startup and recovery information.
1042+
*/
1043+
progress: {
1044+
/**
1045+
* Internal name of the feature that is currently being prepared, started, stopped or unprepared.
1046+
*/
1047+
feature: string;
1048+
/**
1049+
* Name of the lifecycle phase the instance is currently in.
1050+
*/
1051+
phase: string;
1052+
/**
1053+
* Current recovery sequence number value.
1054+
*/
1055+
recoveryTick: number;
1056+
};
1057+
/**
1058+
* Whether writes are disabled.
1059+
*/
1060+
readOnly: boolean;
1061+
/**
1062+
* (Cluster only.) The reboot ID. Changes on every restart.
1063+
*/
1064+
rebootId?: number;
1065+
/**
1066+
* Either "SINGLE", "COORDINATOR", "PRIMARY" (DB-Server), or "AGENT"
1067+
*/
1068+
role: "SINGLE" | "COORDINATOR" | "PRIMARY" | "AGENT";
1069+
/**
1070+
* (Cluster Coordinators and DB-Servers only.) The server ID.
1071+
*/
1072+
serverId?: string;
1073+
/**
1074+
* (Cluster Coordinators and DB-Servers only.) Either "STARTUP", "SERVING",
1075+
* or "SHUTDOWN".
1076+
*/
1077+
state?: "STARTUP" | "SERVING" | "SHUTDOWN";
1078+
/**
1079+
* The server version string.
1080+
*/
1081+
version: string;
1082+
/**
1083+
* Whether writes are enabled.
1084+
*
1085+
* @deprecated Use `readOnly` instead.
1086+
*/
1087+
writeOpsEnabled: boolean;
1088+
};
1089+
};
1090+
9331091
/**
9341092
* Result of retrieving database version information.
9351093
*/
@@ -1865,6 +2023,25 @@ export class Database {
18652023
return this._name;
18662024
}
18672025

2026+
/**
2027+
* Fetches information about the server status.
2028+
*
2029+
* @example
2030+
* ```js
2031+
* const status = await db.status();
2032+
* // the status object contains the ArangoDB status information, e.g.
2033+
* // version: ArangoDB version number
2034+
* // host: host identifier of the server
2035+
* // serverInfo: detailed information about the server
2036+
* ```
2037+
*/
2038+
serverStatus(): Promise<ServerStatusInformation> {
2039+
return this.request({
2040+
method: "GET",
2041+
path: "/_admin/status",
2042+
});
2043+
}
2044+
18682045
/**
18692046
* Fetches version information from the ArangoDB server.
18702047
*

0 commit comments

Comments
 (0)