Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for litd subserver status RPC #19

Merged
merged 2 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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