Skip to content

Commit

Permalink
fix(types): queue tolerance
Browse files Browse the repository at this point in the history
  • Loading branch information
SkeLLLa committed Jan 3, 2025
1 parent caa34c1 commit 9719af7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/client/broker/transport/json/undici.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class PinotBrokerJSONTransport implements IPinotBrokerTransport {
}: IBrokerTransportRequestOptions): Promise<TResponse> {
const queueSize = this.pool.stats.queued;
const maxQueueTolerance =
this.maxQueueSize && typeof options?.queueTolerance !== 'undefined'
this.maxQueueSize && options?.queueTolerance !== undefined
? this.maxQueueSize * options.queueTolerance
: 1;
if (queueSize >= maxQueueTolerance) {
Expand Down
5 changes: 3 additions & 2 deletions src/client/broker/transport/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Dispatcher } from 'undici';
import { IPinotPoolStats } from '../types';
import { IPinotPoolStats, TQueueTolerancePredefined } from '../types';

/**
* Pinot broker transport config options
Expand Down Expand Up @@ -76,7 +76,8 @@ export interface IBrokerTransportRequestOptions
> {
options?:
| {
queueTolerance?: number | undefined;
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
queueTolerance?: TQueueTolerancePredefined | number | undefined;
}
| undefined;
}
Expand Down
7 changes: 5 additions & 2 deletions src/client/broker/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,10 @@ export const enum EBrokerErrorCode {
UNKNOWN,
}

type QueueTolerancePredefined =
/**
* Predefined queue tolerance values.
*/
export type TQueueTolerancePredefined =
| 0
| 0.1
| 0.2
Expand Down Expand Up @@ -315,7 +318,7 @@ export interface IPinotQueryOptions {
*
* @defaultValue 1
*/
queueTolerance?: QueueTolerancePredefined | number;
queueTolerance?: TQueueTolerancePredefined | number;
}

/**
Expand Down

0 comments on commit 9719af7

Please sign in to comment.