separate compression algorithms to avoid circular dependency

This commit is contained in:
Robert 2021-10-26 13:51:42 -07:00
parent 6d75ea1ab6
commit 21b09e25ba
4 changed files with 27 additions and 8 deletions

View File

@ -15,6 +15,8 @@
*
*/
import { CompressionAlgorithms } from './compression-algorithms';
/**
* An interface that contains options used when initializing a Channel instance.
*/
@ -36,7 +38,7 @@ export interface ChannelOptions {
'grpc.enable_http_proxy'?: number;
'grpc.http_connect_target'?: string;
'grpc.http_connect_creds'?: string;
'grpc.default_compression_algorithm'?: number;
'grpc.default_compression_algorithm'?: keyof typeof CompressionAlgorithms;
'grpc-node.max_session_memory'?: number;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[key: string]: any;

View File

@ -0,0 +1,22 @@
/*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
export const CompressionAlgorithms = {
0: 'identity',
1: 'deflate',
2: 'gzip'
} as const;

View File

@ -19,16 +19,11 @@ import * as zlib from 'zlib';
import { Call, WriteObject, WriteFlags } from './call-stream';
import { Channel } from './channel';
import { CompressionAlgorithms } from './compression-algorithms';
import { BaseFilter, Filter, FilterFactory } from './filter';
import { Metadata, MetadataValue } from './metadata';
import { ChannelOptions } from './channel-options';
export const CompressionAlgorithms = {
0: 'identity',
1: 'deflate',
2: 'gzip'
} as const;
const CompressionAlgorithKeys = new Set(Object.keys(CompressionAlgorithms));
const isCompressionAlgorithmKey = (key: number | undefined): key is keyof typeof CompressionAlgorithms => {

View File

@ -25,7 +25,7 @@ import {
import { CallCredentials, OAuth2Client } from './call-credentials';
import { Deadline, StatusObject } from './call-stream';
import { Channel, ChannelImplementation } from './channel';
import { CompressionAlgorithms } from './compression-filter';
import { CompressionAlgorithms } from './compression-algorithms';
import { ConnectivityState } from './connectivity-state';
import { ChannelCredentials } from './channel-credentials';
import {