Skip to content

Commit

Permalink
Add TypeScript declaration for LB strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
lutovich committed Jul 11, 2017
1 parent bedaebb commit 576d9b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions test/types/v1/driver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import Driver, {
AuthToken,
Config,
EncryptionLevel,
LoadBalancingStrategy,
READ,
SessionMode,
TrustStrategy,
Expand Down Expand Up @@ -54,6 +55,8 @@ const trustedCertificates: undefined | string[] = config.trustedCertificates;
const knownHosts: undefined | string = config.knownHosts;
const connectionPoolSize: undefined | number = config.connectionPoolSize;
const maxTransactionRetryTime: undefined | number = config.maxTransactionRetryTime;
const loadBalancingStrategy1: string = config.loadBalancingStrategy;
const loadBalancingStrategy2: LoadBalancingStrategy = config.loadBalancingStrategy;

const sessionMode: SessionMode = dummy;
const sessionModeStr: string = sessionMode;
Expand Down
5 changes: 4 additions & 1 deletion types/v1/driver.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,16 @@ declare type TrustStrategy =
"TRUST_CUSTOM_CA_SIGNED_CERTIFICATES" |
"TRUST_SYSTEM_CA_SIGNED_CERTIFICATES";

declare type LoadBalancingStrategy = "least_connected" | "round_robin";

declare interface Config {
encrypted?: boolean | EncryptionLevel;
trust?: TrustStrategy;
trustedCertificates?: string[];
knownHosts?: string;
connectionPoolSize?: number;
maxTransactionRetryTime?: number;
loadBalancingStrategy?: LoadBalancingStrategy;
}

declare type SessionMode = "READ" | "WRITE";
Expand All @@ -56,6 +59,6 @@ declare interface Driver {
close(): void;
}

export {Driver, READ, WRITE, AuthToken, Config, EncryptionLevel, TrustStrategy, SessionMode}
export {Driver, READ, WRITE, AuthToken, Config, EncryptionLevel, TrustStrategy, LoadBalancingStrategy, SessionMode}

export default Driver;

0 comments on commit 576d9b4

Please sign in to comment.