add boot param to logs subscription

This commit is contained in:
Matt Hill
2024-06-20 10:07:39 -06:00
parent 355452cdb3
commit c6c97491ac
5 changed files with 17 additions and 8 deletions

View File

@@ -62,7 +62,7 @@ export class LogsComponent {
| 'connected'
| 'reconnecting'
| 'disconnected' = 'connecting'
limit = 400
limit = 200
count = 0
constructor(

View File

@@ -18,7 +18,7 @@ export class LogsPage {
loading = true
needInfinite = true
startCursor?: string
limit = 200
limit = 400
isOnBottom = true
constructor(

View File

@@ -35,7 +35,9 @@ function convertAnsi(entries: readonly any[]): string {
@Injectable({ providedIn: 'root' })
export class LogsService extends Observable<readonly string[]> {
private readonly api = inject(ApiService)
private readonly log$ = defer(() => this.api.initFollowLogs({})).pipe(
private readonly log$ = defer(() =>
this.api.initFollowLogs({ boot: 0 }),
).pipe(
switchMap(({ guid }) => this.api.openWebsocket$<Log>(guid, {})),
bufferTime(250),
filter(logs => !!logs.length),

View File

@@ -70,7 +70,12 @@ export module RR {
export type GetServerLogsReq = ServerLogsReq // server.logs & server.kernel-logs
export type GetServerLogsRes = LogsRes
export type FollowServerLogsReq = { limit?: number } // server.logs.follow & server.kernel-logs.follow
// @param limit: BE default is 50
// @param boot: number is offset (0: current, -1 prev, +1 first), string is a specific boot id, and null is all
export type FollowServerLogsReq = {
limit?: number
boot?: number | string | null
} // server.logs.follow & server.kernel-logs.follow
export type FollowServerLogsRes = {
startCursor: string
guid: string

View File

@@ -160,8 +160,10 @@ export class LiveApiService extends ApiService {
return this.rpcRequest({ method: 'init.subscribe', params: {} })
}
async initFollowLogs(): Promise<RR.FollowServerLogsRes> {
return this.rpcRequest({ method: 'init.logs.follow', params: {} })
async initFollowLogs(
params: RR.FollowServerLogsReq,
): Promise<RR.FollowServerLogsRes> {
return this.rpcRequest({ method: 'init.logs.follow', params })
}
// server
@@ -379,8 +381,8 @@ export class LiveApiService extends ApiService {
}
async followPackageLogs(
params: RR.FollowServerLogsReq,
): Promise<RR.FollowServerLogsRes> {
params: RR.FollowPackageLogsReq,
): Promise<RR.FollowPackageLogsRes> {
return this.rpcRequest({ method: 'package.logs.follow', params })
}