-
Notifications
You must be signed in to change notification settings - Fork 893
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
[OE] Support compression for requests #6366
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
feat: | ||
- Support compressing traffic with `opensearch.compression: true` or `opensearch.compress: 'gzip'` ([#6366](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6366)) |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -32,12 +32,14 @@ import { schema, TypeOf } from '@osd/config-schema'; | |||||
import { Duration } from 'moment'; | ||||||
import { readFileSync } from 'fs'; | ||||||
import { ConfigDeprecationProvider } from 'src/core/server'; | ||||||
import { ClientOptions } from '@opensearch-project/opensearch'; | ||||||
import { readPkcs12Keystore, readPkcs12Truststore } from '../utils'; | ||||||
import { ServiceConfigDescriptor } from '../internal_types'; | ||||||
|
||||||
const hostURISchema = schema.uri({ scheme: ['http', 'https'] }); | ||||||
|
||||||
export const DEFAULT_API_VERSION = '7.x'; | ||||||
export const DEFAULT_COMPRESSION = 'gzip'; | ||||||
|
||||||
export type OpenSearchConfigType = TypeOf<typeof configSchema>; | ||||||
type SslConfigSchema = OpenSearchConfigType['ssl']; | ||||||
|
@@ -131,6 +133,9 @@ export const configSchema = schema.object({ | |||||
healthCheck: schema.object({ delay: schema.duration({ defaultValue: 2500 }) }), | ||||||
ignoreVersionMismatch: schema.boolean({ defaultValue: false }), | ||||||
disablePrototypePoisoningProtection: schema.maybe(schema.boolean({ defaultValue: false })), | ||||||
compression: schema.maybe( | ||||||
schema.oneOf([schema.literal(DEFAULT_COMPRESSION), schema.boolean({ defaultValue: false })]) | ||||||
), | ||||||
}); | ||||||
|
||||||
const deprecations: ConfigDeprecationProvider = ({ renameFromRoot, renameFromRootWithoutMap }) => [ | ||||||
|
@@ -313,6 +318,12 @@ export class OpenSearchConfig { | |||||
*/ | ||||||
public readonly disablePrototypePoisoningProtection?: boolean; | ||||||
|
||||||
/** | ||||||
* Specifies whether the client should use compression to engine | ||||||
* or not. | ||||||
*/ | ||||||
public readonly compression?: ClientOptions['compression']; | ||||||
|
||||||
constructor(rawConfig: OpenSearchConfigType) { | ||||||
this.ignoreVersionMismatch = rawConfig.ignoreVersionMismatch; | ||||||
this.apiVersion = rawConfig.apiVersion; | ||||||
|
@@ -334,6 +345,12 @@ export class OpenSearchConfig { | |||||
this.password = rawConfig.password; | ||||||
this.customHeaders = rawConfig.customHeaders; | ||||||
this.disablePrototypePoisoningProtection = rawConfig.disablePrototypePoisoningProtection; | ||||||
this.compression = | ||||||
typeof rawConfig.compression === 'boolean' && rawConfig.compression | ||||||
? DEFAULT_COMPRESSION | ||||||
: typeof rawConfig.compression === 'string' | ||||||
? rawConfig.compression | ||||||
: undefined; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An expression of
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, for the sanity of future devs, can we not use nested ternaries, especially without parens? calling a function with readable if statements isn't the worst thing imo :) |
||||||
|
||||||
const { alwaysPresentCertificate, verificationMode } = rawConfig.ssl; | ||||||
const { key, keyPassphrase, certificate, certificateAuthorities } = readKeyAndCerts(rawConfig); | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want to add a test for this given we updated the test to not do this by default?