Skip to content

Commit

Permalink
lib: Add lit subserver status rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
itsrachelfish committed Jul 26, 2023
1 parent e346bb0 commit 5eb5809
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/api/lit.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Autopilot, Firewall, Sessions } from '../types/proto/litrpc';
import { Autopilot, Firewall, Sessions, Status } from '../types/proto/litrpc';
import { serviceNames as sn } from '../types/proto/schema';

/**
Expand All @@ -8,11 +8,13 @@ class LitApi {
autopilot: Autopilot;
firewall: Firewall;
sessions: Sessions;
status: Status;

constructor(createRpc: Function, lnc: any) {
this.autopilot = createRpc(sn.litrpc.Autopilot, lnc);
this.firewall = createRpc(sn.litrpc.Firewall, lnc);
this.sessions = createRpc(sn.litrpc.Sessions, lnc);
this.status = createRpc(sn.litrpc.Status, lnc);
}
}

Expand Down
48 changes: 48 additions & 0 deletions lib/types/proto/lit/lit-status.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/* eslint-disable */
export interface SubServerStatusReq {}

export interface SubServerStatusResp {
/** A map of sub-server names to their status. */
subServers: { [key: string]: SubServerStatus };
}

export interface SubServerStatusResp_SubServersEntry {
key: string;
value: SubServerStatus | undefined;
}

export interface SubServerStatus {
/** running is true if the sub-server is currently running. */
running: boolean;
/**
* error describes an error that might have resulted in the sub-server not
* starting up properly.
*/
error: string;
}

/** The Status server can be used to query the state of various LiT sub-servers. */
export interface Status {
subServerStatus(
request?: DeepPartial<SubServerStatusReq>
): Promise<SubServerStatusResp>;
}

type Builtin =
| Date
| Function
| Uint8Array
| string
| number
| boolean
| undefined;

type DeepPartial<T> = T extends Builtin
? T
: T extends Array<infer U>
? Array<DeepPartial<U>>
: T extends ReadonlyArray<infer U>
? ReadonlyArray<DeepPartial<U>>
: T extends {}
? { [K in keyof T]?: DeepPartial<T[K]> }
: Partial<T>;
1 change: 1 addition & 0 deletions lib/types/proto/litrpc.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './lit/firewall';
export * from './lit/lit-autopilot';
export * from './lit/lit-sessions';
export * from './lit/lit-status';
3 changes: 2 additions & 1 deletion lib/types/proto/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export const serviceNames = {
litrpc: {
Firewall: 'litrpc.Firewall',
Autopilot: 'litrpc.Autopilot',
Sessions: 'litrpc.Sessions'
Sessions: 'litrpc.Sessions',
Status: 'litrpc.Status'
},
autopilotrpc: { Autopilot: 'autopilotrpc.Autopilot' },
chainrpc: { ChainNotifier: 'chainrpc.ChainNotifier' },
Expand Down

0 comments on commit 5eb5809

Please sign in to comment.