Skip to content

Commit

Permalink
[ML] Add comments to lib functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
walterra committed May 16, 2022
1 parent c8e95df commit 08c920d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions x-pack/plugins/aiops/server/lib/accept_compression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@

import type { Headers } from '@kbn/core/server';

/**
* Returns whether request headers accept a response using gzip compression.
*
* @param headers - Request headers.
* @returns boolean
*/
export function acceptCompression(headers: Headers) {
let compressed = false;

Expand Down
8 changes: 8 additions & 0 deletions x-pack/plugins/aiops/server/lib/stream_factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ class ResponseStream extends Stream.PassThrough {

const DELIMITER = '\n';

/**
* Sets up a response stream with support for gzip compression depending on provided
* request headers.
*
* @param logger - Kibana provided logger.
* @param headers - Request headers.
* @returns An object with stream attributes and methods.
*/
export function streamFactory<T extends ApiEndpoint>(logger: Logger, headers: Headers) {
const isCompressed = acceptCompression(headers);

Expand Down

0 comments on commit 08c920d

Please sign in to comment.