Skip to content

Commit

Permalink
Merge pull request #19 from lightninglabs/lit-subserver-status
Browse files Browse the repository at this point in the history
Add support for litd subserver status RPC
  • Loading branch information
jamaljsr authored Oct 19, 2023
2 parents 1367fe0 + 13d0919 commit bf6a037
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 4 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
53 changes: 53 additions & 0 deletions lib/types/proto/lit/lit-status.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/* 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 {
/**
* disabled is true if the sub-server is available in the LiT package but
* has explicitly been disabled.
*/
disabled: boolean;
/** 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
6 changes: 4 additions & 2 deletions scripts/generate_types.sh
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ protoc/bin/protoc \
$TS_PROTO_OPTIONS \
firewall.proto \
lit-sessions.proto \
lit-autopilot.proto
lit-autopilot.proto \
lit-status.proto

# Temporarily generate schema files in order to provide metadata
# about the services and subscription methods to the api classes
Expand Down Expand Up @@ -217,7 +218,8 @@ protoc/bin/protoc \
$SCHEMA_PROTO_OPTIONS \
firewall.proto \
lit-sessions.proto \
lit-autopilot.proto
lit-autopilot.proto \
lit-status.proto

# Cleanup proto directory/files
rm -rf *.proto protoc
Expand Down

0 comments on commit bf6a037

Please sign in to comment.