mirror of
https://github.com/elastic/kibana.git
synced 2025-07-02 04:53:22 -04:00
This creates a response_stream plugin in the Kibana /examples section. The plugin demonstrates API endpoints that can stream data chunks with a single request with gzip/compression support. gzip-streams get decompressed natively by browsers. The plugin demonstrates two use cases to get started: Streaming a raw string as well as a more complex example that streams Redux-like actions to the client which update React state via useReducer().
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
/*
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
* Side Public License, v 1.
|
|
*/
|
|
|
|
import type {
|
|
UseFetchStreamCustomReducerParams,
|
|
UseFetchStreamParamsDefault,
|
|
} from '@kbn/aiops-utils';
|
|
|
|
import {
|
|
reducerStreamReducer,
|
|
ReducerStreamRequestBodySchema,
|
|
ReducerStreamApiAction,
|
|
} from './reducer_stream';
|
|
import { SimpleStringStreamRequestBodySchema } from './simple_string_stream';
|
|
|
|
export const API_ENDPOINT = {
|
|
REDUCER_STREAM: '/internal/response_stream/reducer_stream',
|
|
SIMPLE_STRING_STREAM: '/internal/response_stream/simple_string_stream',
|
|
} as const;
|
|
|
|
export interface ApiReducerStream extends UseFetchStreamCustomReducerParams {
|
|
endpoint: typeof API_ENDPOINT.REDUCER_STREAM;
|
|
reducer: typeof reducerStreamReducer;
|
|
body: ReducerStreamRequestBodySchema;
|
|
actions: ReducerStreamApiAction;
|
|
}
|
|
|
|
export interface ApiSimpleStringStream extends UseFetchStreamParamsDefault {
|
|
endpoint: typeof API_ENDPOINT.SIMPLE_STRING_STREAM;
|
|
body: SimpleStringStreamRequestBodySchema;
|
|
}
|