Skip to content

Commit f6e961f

Browse files
committed
feat(NODE-1837): adding level option to client and uri
1 parent 43bf2c6 commit f6e961f

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

src/cmap/connection.ts

+4
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,10 @@ function write(
795795
if (conn[kDescription].zlibCompressionLevel) {
796796
operationDescription.zlibCompressionLevel = conn[kDescription].zlibCompressionLevel;
797797
}
798+
799+
if (conn[kDescription].zstdCompressionLevel) {
800+
operationDescription.zstdCompressionLevel = conn[kDescription].zstdCompressionLevel;
801+
}
798802
}
799803

800804
if (typeof options.socketTimeoutMS === 'number') {

src/cmap/stream_description.ts

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export class StreamDescription {
3636
__nodejs_mock_server__?: boolean;
3737

3838
zlibCompressionLevel?: number;
39+
zstdCompressionLevel?: number;
3940

4041
constructor(address: string, options?: StreamDescriptionOptions) {
4142
this.address = address;

src/connection_string.ts

+4
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,10 @@ export const OPTIONS = {
12101210
default: 0,
12111211
type: 'int'
12121212
},
1213+
zstdCompressionLevel: {
1214+
default: 3,
1215+
type: 'int'
1216+
},
12131217
// Custom types for modifying core behavior
12141218
connectionType: { type: 'any' },
12151219
srvPoller: { type: 'any' },

src/mongo_client.ts

+27
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,32 @@ export interface MongoClientOptions extends BSONSerializeOptions, SupportedNodeC
127127
compressors?: CompressorName[] | string;
128128
/** An integer that specifies the compression level if using zlib for network compression. */
129129
zlibCompressionLevel?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | undefined;
130+
/** An integer specifying zstd compression level. */
131+
zstdCompressionLevel?:
132+
| 0
133+
| 1
134+
| 2
135+
| 3
136+
| 4
137+
| 5
138+
| 6
139+
| 7
140+
| 8
141+
| 9
142+
| 10
143+
| 11
144+
| 12
145+
| 13
146+
| 14
147+
| 15
148+
| 16
149+
| 17
150+
| 18
151+
| 19
152+
| 20
153+
| 21
154+
| 22
155+
| undefined;
130156
/** The maximum number of hosts to connect to when using an srv connection string, a setting of `0` means unlimited hosts */
131157
srvMaxHosts?: number;
132158
/**
@@ -658,6 +684,7 @@ export interface MongoOptions
658684
| 'tlsInsecure'
659685
| 'waitQueueTimeoutMS'
660686
| 'zlibCompressionLevel'
687+
| 'zstdCompressionLevel'
661688
>
662689
>,
663690
SupportedNodeConnectionOptions {

0 commit comments

Comments
 (0)