Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
w1am committed Feb 3, 2025
1 parent b5055c0 commit 9bc6e91
Show file tree
Hide file tree
Showing 96 changed files with 63 additions and 14,357 deletions.
47 changes: 32 additions & 15 deletions packages/db-client/src/Client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ export class Client {
}

return new Client(
rustClient,
{
discover,
nodePreference: options.nodePreference,
Expand All @@ -266,13 +265,13 @@ export class Client {
connectionName: options.connectionName,
},
channelCredentials,
options.defaultCredentials
options.defaultCredentials,
rustClient
);
}

if (options.hosts.length > 1) {
return new Client(
rustClient,
{
endpoints: options.hosts,
nodePreference: options.nodePreference,
Expand All @@ -286,12 +285,12 @@ export class Client {
connectionName: options.connectionName,
},
channelCredentials,
options.defaultCredentials
options.defaultCredentials,
rustClient
);
}

return new Client(
rustClient,
{
endpoint: options.hosts[0],
throwOnAppendFailure: options.throwOnAppendFailure,
Expand All @@ -301,30 +300,30 @@ export class Client {
connectionName: options.connectionName,
},
channelCredentials,
options.defaultCredentials
options.defaultCredentials,
rustClient,
);
}

constructor(
rustClient: bridge.RustClient,
connectionSettings: DNSClusterOptions,
channelCredentials?: ChannelCredentialOptions,
defaultUserCredentials?: Credentials
defaultUserCredentials?: Credentials,
rustClient?: bridge.RustClient,
);
constructor(
rustClient: bridge.RustClient,
connectionSettings: GossipClusterOptions,
channelCredentials?: ChannelCredentialOptions,
defaultUserCredentials?: Credentials
defaultUserCredentials?: Credentials,
rustClient?: bridge.RustClient,
);
constructor(
rustClient: bridge.RustClient,
connectionSettings: SingleNodeOptions,
channelCredentials?: ChannelCredentialOptions,
defaultUserCredentials?: Credentials
defaultUserCredentials?: Credentials,
rustClient?: bridge.RustClient,
);
constructor(
rustClient: bridge.RustClient,
{
throwOnAppendFailure = true,
keepAliveInterval = 10_000,
Expand All @@ -334,7 +333,8 @@ export class Client {
...connectionSettings
}: ConnectionSettings,
channelCredentials: ChannelCredentialOptions = { insecure: false },
defaultUserCredentials?: Credentials
defaultUserCredentials?: Credentials,
rustClient?: bridge.RustClient,
) {
if (keepAliveInterval < -1) {
throw new Error(
Expand Down Expand Up @@ -366,7 +366,6 @@ export class Client {
);
}

this.#rustClient = rustClient;
this.#throwOnAppendFailure = throwOnAppendFailure;
this.#keepAliveInterval = keepAliveInterval;
this.#keepAliveTimeout = keepAliveTimeout;
Expand All @@ -377,6 +376,24 @@ export class Client {
this.#connectionName = connectionName;
this.#http = new HTTP(this, channelCredentials, defaultUserCredentials);

let newRustClient: bridge.RustClient | undefined = rustClient;

if (newRustClient === undefined) {
if ("endpoint" in connectionSettings) {
newRustClient = bridge.createClient((this.#connectionSettings as SingleNodeOptions).endpoint.toString());
} else if ("endpoints" in connectionSettings) {
newRustClient = bridge.createClient((this.#connectionSettings as GossipClusterOptions).endpoints.reduce<string>(
(acc, chunk, i) => `${acc}${chunk}${(this.#connectionSettings as GossipClusterOptions).endpoints[i] ?? ""}`,
""));
} else if ("discover" in connectionSettings) {
newRustClient = bridge.createClient((this.#connectionSettings as GossipClusterOptions).endpoints.reduce<string>(
(acc, chunk, i) => `${acc}${chunk}${(this.#connectionSettings as GossipClusterOptions).endpoints[i] ?? ""}`,
""));
}
}

this.#rustClient = newRustClient!;

if (this.#insecure) {
debug.connection("Using insecure channel");
this.#channelCredentials = grpcCredentials.createInsecure();
Expand Down
47 changes: 0 additions & 47 deletions packages/test/src/connection/Channel.test.ts

This file was deleted.

89 changes: 0 additions & 89 deletions packages/test/src/connection/__snapshots__/keepAlive.test.ts.snap

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 9bc6e91

Please sign in to comment.