Skip to content

Commit 13d0919

Browse files
committed
lib: Add lit subserver status rpc
1 parent 6c3ed16 commit 13d0919

File tree

4 files changed

+59
-2
lines changed

4 files changed

+59
-2
lines changed

lib/api/lit.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Autopilot, Firewall, Sessions } from '../types/proto/litrpc';
1+
import { Autopilot, Firewall, Sessions, Status } from '../types/proto/litrpc';
22
import { serviceNames as sn } from '../types/proto/schema';
33

44
/**
@@ -8,11 +8,13 @@ class LitApi {
88
autopilot: Autopilot;
99
firewall: Firewall;
1010
sessions: Sessions;
11+
status: Status;
1112

1213
constructor(createRpc: Function, lnc: any) {
1314
this.autopilot = createRpc(sn.litrpc.Autopilot, lnc);
1415
this.firewall = createRpc(sn.litrpc.Firewall, lnc);
1516
this.sessions = createRpc(sn.litrpc.Sessions, lnc);
17+
this.status = createRpc(sn.litrpc.Status, lnc);
1618
}
1719
}
1820

lib/types/proto/lit/lit-status.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/* eslint-disable */
2+
export interface SubServerStatusReq {}
3+
4+
export interface SubServerStatusResp {
5+
/** A map of sub-server names to their status. */
6+
subServers: { [key: string]: SubServerStatus };
7+
}
8+
9+
export interface SubServerStatusResp_SubServersEntry {
10+
key: string;
11+
value: SubServerStatus | undefined;
12+
}
13+
14+
export interface SubServerStatus {
15+
/**
16+
* disabled is true if the sub-server is available in the LiT package but
17+
* has explicitly been disabled.
18+
*/
19+
disabled: boolean;
20+
/** running is true if the sub-server is currently running. */
21+
running: boolean;
22+
/**
23+
* error describes an error that might have resulted in the sub-server not
24+
* starting up properly.
25+
*/
26+
error: string;
27+
}
28+
29+
/** The Status server can be used to query the state of various LiT sub-servers. */
30+
export interface Status {
31+
subServerStatus(
32+
request?: DeepPartial<SubServerStatusReq>
33+
): Promise<SubServerStatusResp>;
34+
}
35+
36+
type Builtin =
37+
| Date
38+
| Function
39+
| Uint8Array
40+
| string
41+
| number
42+
| boolean
43+
| undefined;
44+
45+
type DeepPartial<T> = T extends Builtin
46+
? T
47+
: T extends Array<infer U>
48+
? Array<DeepPartial<U>>
49+
: T extends ReadonlyArray<infer U>
50+
? ReadonlyArray<DeepPartial<U>>
51+
: T extends {}
52+
? { [K in keyof T]?: DeepPartial<T[K]> }
53+
: Partial<T>;

lib/types/proto/litrpc.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from './lit/firewall';
22
export * from './lit/lit-autopilot';
33
export * from './lit/lit-sessions';
4+
export * from './lit/lit-status';

lib/types/proto/schema.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export const serviceNames = {
88
litrpc: {
99
Firewall: 'litrpc.Firewall',
1010
Autopilot: 'litrpc.Autopilot',
11-
Sessions: 'litrpc.Sessions'
11+
Sessions: 'litrpc.Sessions',
12+
Status: 'litrpc.Status'
1213
},
1314
autopilotrpc: { Autopilot: 'autopilotrpc.Autopilot' },
1415
chainrpc: { ChainNotifier: 'chainrpc.ChainNotifier' },

0 commit comments

Comments
 (0)