Skip to content

Commit ae2bf28

Browse files
committed
Node: Rename RedisClient, RedisClusterClient to GlideClient, GlideClusterClient
1 parent fe08390 commit ae2bf28

File tree

14 files changed

+98
-578
lines changed

14 files changed

+98
-578
lines changed

benchmarks/node/node_benchmark.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
import { writeFileSync } from "fs";
6-
import { Logger, RedisClient, RedisClusterClient } from "glide-for-redis";
6+
import { GlideClient, GlideClusterClient, Logger } from "glide-for-redis";
77
import { Cluster, Redis } from "ioredis";
88
import { parse } from "path";
99
import percentile from "percentile";
@@ -216,8 +216,8 @@ async function main(
216216

217217
if (clientsToRun == "all" || clientsToRun == "glide") {
218218
const clientClass = clusterModeEnabled
219-
? RedisClusterClient
220-
: RedisClient;
219+
? GlideClusterClient
220+
: GlideClient;
221221
const clients = await createClients(clientCount, () =>
222222
clientClass.createClient({
223223
addresses: [{ host, port }],
@@ -232,19 +232,19 @@ async function main(
232232
dataSize,
233233
data,
234234
(client) => {
235-
(client as RedisClient).close();
235+
(client as GlideClient).close();
236236
},
237237
clusterModeEnabled,
238238
);
239239
await new Promise((resolve) => setTimeout(resolve, 100));
240240
}
241241

242242
if (clientsToRun == "all") {
243-
const nodeRedisClients = await createClients(clientCount, async () => {
243+
const nodeGlideClients = await createClients(clientCount, async () => {
244244
const node = {
245245
url: getAddress(host, useTLS, port),
246246
};
247-
const nodeRedisClient = clusterModeEnabled
247+
const nodeGlideClient = clusterModeEnabled
248248
? createCluster({
249249
rootNodes: [{ socket: { host, port, tls: useTLS } }],
250250
defaults: {
@@ -255,11 +255,11 @@ async function main(
255255
useReplicas: true,
256256
})
257257
: createClient(node);
258-
await nodeRedisClient.connect();
259-
return nodeRedisClient;
258+
await nodeGlideClient.connect();
259+
return nodeGlideClient;
260260
});
261261
await runClients(
262-
nodeRedisClients,
262+
nodeGlideClients,
263263
"node_redis",
264264
totalCommands,
265265
numOfConcurrentTasks,

examples/node/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
33
*/
44

5-
import { Logger, RedisClient, RedisClusterClient } from "@aws/glide-for-redis";
5+
import { GlideClient, GlideClusterClient, Logger } from "@aws/glide-for-redis";
66

77
async function sendPingToNode() {
88
// When in Redis is in standalone mode, add address of the primary node, and any replicas you'd like to be able to read from.
@@ -12,8 +12,8 @@ async function sendPingToNode() {
1212
port: 6379,
1313
},
1414
];
15-
// Check `RedisClientConfiguration/ClusterClientConfiguration` for additional options.
16-
const client = await RedisClient.createClient({
15+
// Check `GlideClientConfiguration/ClusterClientConfiguration` for additional options.
16+
const client = await GlideClient.createClient({
1717
addresses: addresses,
1818
// if the server uses TLS, you'll need to enable it. Otherwise the connection attempt will time out silently.
1919
// useTLS: true,
@@ -26,7 +26,7 @@ async function sendPingToNode() {
2626
client.close();
2727
}
2828

29-
async function send_set_and_get(client: RedisClient | RedisClusterClient) {
29+
async function send_set_and_get(client: GlideClient | GlideClusterClient) {
3030
const set_response = await client.set("foo", "bar");
3131
console.log(`Set response is = ${set_response}`);
3232
const get_response = await client.get("foo");
@@ -41,8 +41,8 @@ async function sendPingToRandomNodeInCluster() {
4141
port: 6380,
4242
},
4343
];
44-
// Check `RedisClientConfiguration/ClusterClientConfiguration` for additional options.
45-
const client = await RedisClusterClient.createClient({
44+
// Check `GlideClientConfiguration/ClusterClientConfiguration` for additional options.
45+
const client = await GlideClusterClient.createClient({
4646
addresses: addresses,
4747
// if the cluster nodes use TLS, you'll need to enable it. Otherwise the connection attempt will time out silently.
4848
// useTLS: true,

node/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ To install GLIDE for Redis using `npm`, follow these steps:
4545
#### Cluster Redis:
4646

4747
```node
48-
import { RedisClusterClient } from "@aws/glide-for-redis";
48+
import { GlideClusterClient } from "@aws/glide-for-redis";
4949
5050
const addresses = [
5151
{
5252
host: "redis.example.com",
5353
port: 6379,
5454
},
5555
];
56-
const client = await RedisClusterClient.createClient({
56+
const client = await GlideClusterClient.createClient({
5757
addresses: addresses,
5858
});
5959
await client.set("foo", "bar");
@@ -64,7 +64,7 @@ client.close();
6464
#### Standalone Redis:
6565
6666
```node
67-
import { RedisClient } from "@aws/glide-for-redis";
67+
import { GlideClient } from "@aws/glide-for-redis";
6868
6969
const addresses = [
7070
{
@@ -76,7 +76,7 @@ const addresses = [
7676
port: 6379,
7777
},
7878
];
79-
const client = await RedisClient.createClient({
79+
const client = await GlideClient.createClient({
8080
addresses: addresses,
8181
});
8282
await client.set("foo", "bar");

node/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export { Script } from "glide-rs";
66
export * from "./src/BaseClient";
77
export * from "./src/Commands";
88
export * from "./src/Errors";
9+
export * from "./src/GlideClient";
10+
export * from "./src/GlideClusterClient";
911
export * from "./src/Logger";
10-
export * from "./src/RedisClient";
11-
export * from "./src/RedisClusterClient";
1212
export * from "./src/Transaction";

node/npm/glide/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ function loadNativeBinding() {
7474
function initialize() {
7575
const nativeBinding = loadNativeBinding();
7676
const {
77-
RedisClient,
78-
RedisClusterClient,
79-
RedisClientConfiguration,
77+
GlideClient,
78+
GlideClusterClient,
79+
GlideClientConfiguration,
8080
SlotIdTypes,
8181
SlotKeyTypes,
8282
RouteByAddress,
@@ -117,9 +117,9 @@ function initialize() {
117117
} = nativeBinding;
118118

119119
module.exports = {
120-
RedisClient,
121-
RedisClusterClient,
122-
RedisClientConfiguration,
120+
GlideClient,
121+
GlideClusterClient,
122+
GlideClientConfiguration,
123123
SlotIdTypes,
124124
SlotKeyTypes,
125125
RouteByAddress,
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
import { connection_request } from "./ProtobufMessage";
2323
import { Transaction } from "./Transaction";
2424

25-
export type RedisClientConfiguration = BaseClientConfiguration & {
25+
export type GlideClientConfiguration = BaseClientConfiguration & {
2626
/**
2727
* index of the logical database to connect to.
2828
*/
@@ -59,12 +59,12 @@ export type RedisClientConfiguration = BaseClientConfiguration & {
5959
* For full documentation, see
6060
* https://github.com/aws/babushka/wiki/NodeJS-wrapper#redis-standalone
6161
*/
62-
export class RedisClient extends BaseClient {
62+
export class GlideClient extends BaseClient {
6363
/**
6464
* @internal
6565
*/
6666
protected createClientRequest(
67-
options: RedisClientConfiguration,
67+
options: GlideClientConfiguration,
6868
): connection_request.IConnectionRequest {
6969
const configuration = super.createClientRequest(options);
7070
configuration.databaseId = options.databaseId;
@@ -73,22 +73,22 @@ export class RedisClient extends BaseClient {
7373
}
7474

7575
public static createClient(
76-
options: RedisClientConfiguration,
77-
): Promise<RedisClient> {
78-
return super.createClientInternal<RedisClient>(
76+
options: GlideClientConfiguration,
77+
): Promise<GlideClient> {
78+
return super.createClientInternal<GlideClient>(
7979
options,
80-
(socket: net.Socket) => new RedisClient(socket),
80+
(socket: net.Socket) => new GlideClient(socket),
8181
);
8282
}
8383

8484
static async __createClient(
8585
options: BaseClientConfiguration,
8686
connectedSocket: net.Socket,
87-
): Promise<RedisClient> {
87+
): Promise<GlideClient> {
8888
return this.__createClientInternal(
8989
options,
9090
connectedSocket,
91-
(socket, options) => new RedisClient(socket, options),
91+
(socket, options) => new GlideClient(socket, options),
9292
);
9393
}
9494

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ function toProtobufRoute(
204204
* For full documentation, see
205205
* https://github.com/aws/babushka/wiki/NodeJS-wrapper#redis-cluster
206206
*/
207-
export class RedisClusterClient extends BaseClient {
207+
export class GlideClusterClient extends BaseClient {
208208
/**
209209
* @internal
210210
*/
@@ -235,22 +235,22 @@ export class RedisClusterClient extends BaseClient {
235235

236236
public static async createClient(
237237
options: ClusterClientConfiguration,
238-
): Promise<RedisClusterClient> {
238+
): Promise<GlideClusterClient> {
239239
return await super.createClientInternal(
240240
options,
241241
(socket: net.Socket, options?: ClusterClientConfiguration) =>
242-
new RedisClusterClient(socket, options),
242+
new GlideClusterClient(socket, options),
243243
);
244244
}
245245

246246
static async __createClient(
247247
options: BaseClientConfiguration,
248248
connectedSocket: net.Socket,
249-
): Promise<RedisClusterClient> {
249+
): Promise<GlideClusterClient> {
250250
return super.__createClientInternal(
251251
options,
252252
connectedSocket,
253-
(socket, options) => new RedisClusterClient(socket, options),
253+
(socket, options) => new GlideClusterClient(socket, options),
254254
);
255255
}
256256

node/src/Transaction.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,7 +1529,7 @@ export class BaseTransaction<T extends BaseTransaction<T>> {
15291529
* Transactions allow the execution of a group of commands in a single step.
15301530
*
15311531
* Command Response:
1532-
* An array of command responses is returned by the RedisClient.exec command, in the order they were given.
1532+
* An array of command responses is returned by the GlideClient.exec command, in the order they were given.
15331533
* Each element in the array represents a command given to the transaction.
15341534
* The response for each command depends on the executed Redis command.
15351535
* Specific response types are documented alongside each method.
@@ -1540,7 +1540,7 @@ export class BaseTransaction<T extends BaseTransaction<T>> {
15401540
* .set("key", "value")
15411541
* .select(1) /// Standalone command
15421542
* .get("key");
1543-
* const result = await redisClient.exec(transaction);
1543+
* const result = await GlideClient.exec(transaction);
15441544
* console.log(result); // Output: ['OK', 'OK', null]
15451545
* ```
15461546
*/
@@ -1564,7 +1564,7 @@ export class Transaction extends BaseTransaction<Transaction> {
15641564
* Transactions allow the execution of a group of commands in a single step.
15651565
*
15661566
* Command Response:
1567-
* An array of command responses is returned by the RedisClusterClient.exec command, in the order they were given.
1567+
* An array of command responses is returned by the GlideClusterClient.exec command, in the order they were given.
15681568
* Each element in the array represents a command given to the transaction.
15691569
* The response for each command depends on the executed Redis command.
15701570
* Specific response types are documented alongside each method.

node/tests/RedisClient.test.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
} from "@jest/globals";
1313
import { BufferReader, BufferWriter } from "protobufjs";
1414
import { v4 as uuidv4 } from "uuid";
15-
import { ProtocolVersion, RedisClient, Transaction } from "..";
15+
import { GlideClient, ProtocolVersion, Transaction } from "..";
1616
import { RedisCluster } from "../../utils/TestUtils.js";
1717
import { redis_request } from "../src/ProtobufMessage";
1818
import { runBaseTests } from "./SharedTests";
@@ -30,15 +30,15 @@ import {
3030
/* eslint-disable @typescript-eslint/no-var-requires */
3131

3232
type Context = {
33-
client: RedisClient;
33+
client: GlideClient;
3434
};
3535

3636
const TIMEOUT = 50000;
3737

38-
describe("RedisClient", () => {
38+
describe("GlideClient", () => {
3939
let testsFailed = 0;
4040
let cluster: RedisCluster;
41-
let client: RedisClient;
41+
let client: GlideClient;
4242
beforeAll(async () => {
4343
const standaloneAddresses =
4444
parseCommandLineArgs()["standalone-endpoints"];
@@ -106,7 +106,7 @@ describe("RedisClient", () => {
106106
it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])(
107107
"info without parameters",
108108
async (protocol) => {
109-
client = await RedisClient.createClient(
109+
client = await GlideClient.createClient(
110110
getClientConfigurationOption(cluster.getAddresses(), protocol),
111111
);
112112
const result = await client.info();
@@ -125,7 +125,7 @@ describe("RedisClient", () => {
125125
it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])(
126126
"simple select test",
127127
async (protocol) => {
128-
client = await RedisClient.createClient(
128+
client = await GlideClient.createClient(
129129
getClientConfigurationOption(cluster.getAddresses(), protocol),
130130
);
131131
let selectResult = await client.select(0);
@@ -149,7 +149,7 @@ describe("RedisClient", () => {
149149
it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])(
150150
`can send transactions_%p`,
151151
async (protocol) => {
152-
client = await RedisClient.createClient(
152+
client = await GlideClient.createClient(
153153
getClientConfigurationOption(cluster.getAddresses(), protocol),
154154
);
155155
const transaction = new Transaction();
@@ -164,10 +164,10 @@ describe("RedisClient", () => {
164164
it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])(
165165
"can return null on WATCH transaction failures",
166166
async (protocol) => {
167-
const client1 = await RedisClient.createClient(
167+
const client1 = await GlideClient.createClient(
168168
getClientConfigurationOption(cluster.getAddresses(), protocol),
169169
);
170-
const client2 = await RedisClient.createClient(
170+
const client2 = await GlideClient.createClient(
171171
getClientConfigurationOption(cluster.getAddresses(), protocol),
172172
);
173173
const transaction = new Transaction();
@@ -189,7 +189,7 @@ describe("RedisClient", () => {
189189
it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])(
190190
"object freq transaction test_%p",
191191
async (protocol) => {
192-
const client = await RedisClient.createClient(
192+
const client = await GlideClient.createClient(
193193
getClientConfigurationOption(cluster.getAddresses(), protocol),
194194
);
195195

@@ -230,7 +230,7 @@ describe("RedisClient", () => {
230230
it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])(
231231
"object idletime transaction test_%p",
232232
async (protocol) => {
233-
const client = await RedisClient.createClient(
233+
const client = await GlideClient.createClient(
234234
getClientConfigurationOption(cluster.getAddresses(), protocol),
235235
);
236236

@@ -275,7 +275,7 @@ describe("RedisClient", () => {
275275
it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])(
276276
"object refcount transaction test_%p",
277277
async (protocol) => {
278-
const client = await RedisClient.createClient(
278+
const client = await GlideClient.createClient(
279279
getClientConfigurationOption(cluster.getAddresses(), protocol),
280280
);
281281

@@ -306,7 +306,7 @@ describe("RedisClient", () => {
306306
options.protocol = protocol;
307307
options.clientName = clientName;
308308
testsFailed += 1;
309-
client = await RedisClient.createClient(options);
309+
client = await GlideClient.createClient(options);
310310
return { client, context: { client } };
311311
},
312312
close: (context: Context, testSucceeded: boolean) => {

0 commit comments

Comments
 (0)