feat: Stream consumer groups UI

- stream.ts: streamGroups, streamConsumers, streamGroupCreate, streamGroupDestroy, streamAck
- IPC: redis:streamGroups, streamConsumers, streamGroupCreate, streamGroupDestroy, streamAck
- Preload bridge + types for all new methods
- StreamEditor.vue: collapsible consumer groups panel
  - XINFO GROUPS table with name/consumers/pending/last-delivered-id
  - Click group to expand XINFO CONSUMERS
  - Create group dialog (name, start ID, MKSTREAM)
  - Destroy group with confirm
- i18n keys (zh-CN + en)
- P1 complete!
This commit is contained in:
2026-07-07 21:22:12 +08:00
parent 00c11d4dfe
commit cdadfbe5e4
8 changed files with 379 additions and 4 deletions
+17
View File
@@ -232,6 +232,23 @@ export function registerIpcHandlers(): void {
return redis.streamDel(id, key, ...ids)
}))
// Redis - Stream Consumer Groups
ipcMain.handle('redis:streamGroups', async (_e, id: string, key: string) => {
return redis.streamGroups(id, key)
})
ipcMain.handle('redis:streamConsumers', async (_e, id: string, key: string, group: string) => {
return redis.streamConsumers(id, key, group)
})
ipcMain.handle('redis:streamGroupCreate', withLog('XGROUP CREATE', async (_e, id: string, key: string, group: string, startId: string, mkstream: boolean) => {
return redis.streamGroupCreate(id, key, group, startId, mkstream)
}))
ipcMain.handle('redis:streamGroupDestroy', withLog('XGROUP DESTROY', async (_e, id: string, key: string, group: string) => {
return redis.streamGroupDestroy(id, key, group)
}))
ipcMain.handle('redis:streamAck', withLog('XACK', async (_e, id: string, key: string, group: string, ids: string[]) => {
return redis.streamAck(id, key, group, ...ids)
}))
// Command Log
ipcMain.handle('redis:getCommandLog', () => {
return redis.getLog()
+35
View File
@@ -35,3 +35,38 @@ export async function streamDel(id: string, key: string, ...ids: string[]): Prom
if (!client) throw new Error(`Client ${id} not found`)
return client.xdel(key, ...ids)
}
// Consumer group operations
export async function streamGroups(id: string, key: string): Promise<any[]> {
const client = getClient(id)
if (!client) throw new Error(`Client ${id} not found`)
return client.xinfo('GROUPS', key) as Promise<any[]>
}
export async function streamConsumers(id: string, key: string, group: string): Promise<any[]> {
const client = getClient(id)
if (!client) throw new Error(`Client ${id} not found`)
return client.xinfo('CONSUMERS', key, group) as Promise<any[]>
}
export async function streamGroupCreate(
id: string, key: string, group: string, startId: string, mkstream: boolean
): Promise<string> {
const client = getClient(id)
if (!client) throw new Error(`Client ${id} not found`)
const args: any[] = [key, group, startId]
if (mkstream) args.push('MKSTREAM')
return (client as any).xgroup('CREATE', ...args)
}
export async function streamGroupDestroy(id: string, key: string, group: string): Promise<number> {
const client = getClient(id)
if (!client) throw new Error(`Client ${id} not found`)
return (client as any).xgroup('DESTROY', key, group)
}
export async function streamAck(id: string, key: string, group: string, ...ids: string[]): Promise<number> {
const client = getClient(id)
if (!client) throw new Error(`Client ${id} not found`)
return (client as any).xack(key, group, ...ids)
}
+5
View File
@@ -98,6 +98,11 @@ export interface ElectronAPI {
streamAdd: (id: string, key: string, streamId: string, fieldValues: string[]) => Promise<string>
streamTrim: (id: string, key: string, maxLen: number) => Promise<number>
streamDel: (id: string, key: string, ids: string[]) => Promise<number>
streamGroups: (id: string, key: string) => Promise<any[]>
streamConsumers: (id: string, key: string, group: string) => Promise<any[]>
streamGroupCreate: (id: string, key: string, group: string, startId: string, mkstream: boolean) => Promise<any>
streamGroupDestroy: (id: string, key: string, group: string) => Promise<number>
streamAck: (id: string, key: string, group: string, ids: string[]) => Promise<number>
renameKey: (id: string, oldKey: string, newKey: string) => Promise<void>
existsKey: (id: string, key: string) => Promise<boolean>
ping: (id: string) => Promise<string>
+11
View File
@@ -105,6 +105,17 @@ const electronAPI = {
ipcRenderer.invoke('redis:streamTrim', id, key, maxLen),
streamDel: (id: string, key: string, ids: string[]): Promise<number> =>
ipcRenderer.invoke('redis:streamDel', id, key, ids),
// Stream consumer groups
streamGroups: (id: string, key: string): Promise<any[]> =>
ipcRenderer.invoke('redis:streamGroups', id, key),
streamConsumers: (id: string, key: string, group: string): Promise<any[]> =>
ipcRenderer.invoke('redis:streamConsumers', id, key, group),
streamGroupCreate: (id: string, key: string, group: string, startId: string, mkstream: boolean): Promise<any> =>
ipcRenderer.invoke('redis:streamGroupCreate', id, key, group, startId, mkstream),
streamGroupDestroy: (id: string, key: string, group: string): Promise<number> =>
ipcRenderer.invoke('redis:streamGroupDestroy', id, key, group),
streamAck: (id: string, key: string, group: string, ids: string[]): Promise<number> =>
ipcRenderer.invoke('redis:streamAck', id, key, group, ids),
// Key ops
renameKey: (id: string, oldKey: string, newKey: string): Promise<void> =>
ipcRenderer.invoke('redis:renameKey', id, oldKey, newKey),