Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node: Rename RedisClient, RedisClusterClient to GlideClient, GlideClusterClient #1670

Merged
merged 2 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@

### Breaking Changes
* Node: Update XREAD to return a Map of Map ([#1494](https://github.com/aws/glide-for-redis/pull/1494))
* Node: Rename RedisClient to GlideClient and RedisClusterClient to GlideClusterClient ([#1670](https://github.com/aws/glide-for-redis/pull/1670))

## 0.4.1 (2024-02-06)

Expand Down
18 changes: 9 additions & 9 deletions benchmarks/node/node_benchmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

import { writeFileSync } from "fs";
import { Logger, RedisClient, RedisClusterClient } from "glide-for-redis";
import { GlideClient, GlideClusterClient, Logger } from "glide-for-redis";
import { Cluster, Redis } from "ioredis";
import { parse } from "path";
import percentile from "percentile";
Expand Down Expand Up @@ -216,8 +216,8 @@ async function main(

if (clientsToRun == "all" || clientsToRun == "glide") {
const clientClass = clusterModeEnabled
? RedisClusterClient
: RedisClient;
? GlideClusterClient
: GlideClient;
const clients = await createClients(clientCount, () =>
clientClass.createClient({
addresses: [{ host, port }],
Expand All @@ -232,19 +232,19 @@ async function main(
dataSize,
data,
(client) => {
(client as RedisClient).close();
(client as GlideClient).close();
},
clusterModeEnabled,
);
await new Promise((resolve) => setTimeout(resolve, 100));
}

if (clientsToRun == "all") {
const nodeRedisClients = await createClients(clientCount, async () => {
const nodeGlideClients = await createClients(clientCount, async () => {
const node = {
url: getAddress(host, useTLS, port),
};
const nodeRedisClient = clusterModeEnabled
const nodeGlideClient = clusterModeEnabled
? createCluster({
rootNodes: [{ socket: { host, port, tls: useTLS } }],
defaults: {
Expand All @@ -255,11 +255,11 @@ async function main(
useReplicas: true,
})
: createClient(node);
await nodeRedisClient.connect();
return nodeRedisClient;
await nodeGlideClient.connect();
return nodeGlideClient;
});
await runClients(
nodeRedisClients,
nodeGlideClients,
"node_redis",
totalCommands,
numOfConcurrentTasks,
Expand Down
12 changes: 6 additions & 6 deletions examples/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
*/

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

async function sendPingToNode() {
// 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.
Expand All @@ -12,8 +12,8 @@ async function sendPingToNode() {
port: 6379,
},
];
// Check `RedisClientConfiguration/ClusterClientConfiguration` for additional options.
const client = await RedisClient.createClient({
// Check `GlideClientConfiguration/ClusterClientConfiguration` for additional options.
const client = await GlideClient.createClient({
addresses: addresses,
// if the server uses TLS, you'll need to enable it. Otherwise the connection attempt will time out silently.
// useTLS: true,
Expand All @@ -26,7 +26,7 @@ async function sendPingToNode() {
client.close();
}

async function send_set_and_get(client: RedisClient | RedisClusterClient) {
async function send_set_and_get(client: GlideClient | GlideClusterClient) {
const set_response = await client.set("foo", "bar");
console.log(`Set response is = ${set_response}`);
const get_response = await client.get("foo");
Expand All @@ -41,8 +41,8 @@ async function sendPingToRandomNodeInCluster() {
port: 6380,
},
];
// Check `RedisClientConfiguration/ClusterClientConfiguration` for additional options.
const client = await RedisClusterClient.createClient({
// Check `GlideClientConfiguration/ClusterClientConfiguration` for additional options.
const client = await GlideClusterClient.createClient({
addresses: addresses,
// if the cluster nodes use TLS, you'll need to enable it. Otherwise the connection attempt will time out silently.
// useTLS: true,
Expand Down
8 changes: 4 additions & 4 deletions node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ To install GLIDE for Redis using `npm`, follow these steps:
#### Cluster Redis:

```node
import { RedisClusterClient } from "@aws/glide-for-redis";
import { GlideClusterClient } from "@aws/glide-for-redis";

const addresses = [
{
host: "redis.example.com",
port: 6379,
},
];
const client = await RedisClusterClient.createClient({
const client = await GlideClusterClient.createClient({
addresses: addresses,
});
await client.set("foo", "bar");
Expand All @@ -64,7 +64,7 @@ client.close();
#### Standalone Redis:

```node
import { RedisClient } from "@aws/glide-for-redis";
import { GlideClient } from "@aws/glide-for-redis";

const addresses = [
{
Expand All @@ -76,7 +76,7 @@ const addresses = [
port: 6379,
},
];
const client = await RedisClient.createClient({
const client = await GlideClient.createClient({
addresses: addresses,
});
await client.set("foo", "bar");
Expand Down
4 changes: 2 additions & 2 deletions node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export { Script } from "glide-rs";
export * from "./src/BaseClient";
export * from "./src/Commands";
export * from "./src/Errors";
export * from "./src/GlideClient";
export * from "./src/GlideClusterClient";
export * from "./src/Logger";
export * from "./src/RedisClient";
export * from "./src/RedisClusterClient";
export * from "./src/Transaction";
12 changes: 6 additions & 6 deletions node/npm/glide/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ function loadNativeBinding() {
function initialize() {
const nativeBinding = loadNativeBinding();
const {
RedisClient,
RedisClusterClient,
RedisClientConfiguration,
GlideClient,
GlideClusterClient,
GlideClientConfiguration,
SlotIdTypes,
SlotKeyTypes,
RouteByAddress,
Expand Down Expand Up @@ -117,9 +117,9 @@ function initialize() {
} = nativeBinding;

module.exports = {
RedisClient,
RedisClusterClient,
RedisClientConfiguration,
GlideClient,
GlideClusterClient,
GlideClientConfiguration,
SlotIdTypes,
SlotKeyTypes,
RouteByAddress,
Expand Down
18 changes: 9 additions & 9 deletions node/src/RedisClient.ts → node/src/GlideClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
import { connection_request } from "./ProtobufMessage";
import { Transaction } from "./Transaction";

export type RedisClientConfiguration = BaseClientConfiguration & {
export type GlideClientConfiguration = BaseClientConfiguration & {
/**
* index of the logical database to connect to.
*/
Expand Down Expand Up @@ -59,12 +59,12 @@ export type RedisClientConfiguration = BaseClientConfiguration & {
* For full documentation, see
* https://github.com/aws/babushka/wiki/NodeJS-wrapper#redis-standalone
*/
export class RedisClient extends BaseClient {
export class GlideClient extends BaseClient {
/**
* @internal
*/
protected createClientRequest(
options: RedisClientConfiguration,
options: GlideClientConfiguration,
): connection_request.IConnectionRequest {
const configuration = super.createClientRequest(options);
configuration.databaseId = options.databaseId;
Expand All @@ -73,22 +73,22 @@ export class RedisClient extends BaseClient {
}

public static createClient(
options: RedisClientConfiguration,
): Promise<RedisClient> {
return super.createClientInternal<RedisClient>(
options: GlideClientConfiguration,
): Promise<GlideClient> {
return super.createClientInternal<GlideClient>(
options,
(socket: net.Socket) => new RedisClient(socket),
(socket: net.Socket) => new GlideClient(socket),
);
}

static async __createClient(
options: BaseClientConfiguration,
connectedSocket: net.Socket,
): Promise<RedisClient> {
): Promise<GlideClient> {
return this.__createClientInternal(
options,
connectedSocket,
(socket, options) => new RedisClient(socket, options),
(socket, options) => new GlideClient(socket, options),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ function toProtobufRoute(
* For full documentation, see
* https://github.com/aws/babushka/wiki/NodeJS-wrapper#redis-cluster
*/
export class RedisClusterClient extends BaseClient {
export class GlideClusterClient extends BaseClient {
/**
* @internal
*/
Expand Down Expand Up @@ -235,22 +235,22 @@ export class RedisClusterClient extends BaseClient {

public static async createClient(
options: ClusterClientConfiguration,
): Promise<RedisClusterClient> {
): Promise<GlideClusterClient> {
return await super.createClientInternal(
options,
(socket: net.Socket, options?: ClusterClientConfiguration) =>
new RedisClusterClient(socket, options),
new GlideClusterClient(socket, options),
);
}

static async __createClient(
options: BaseClientConfiguration,
connectedSocket: net.Socket,
): Promise<RedisClusterClient> {
): Promise<GlideClusterClient> {
return super.__createClientInternal(
options,
connectedSocket,
(socket, options) => new RedisClusterClient(socket, options),
(socket, options) => new GlideClusterClient(socket, options),
);
}

Expand Down
6 changes: 3 additions & 3 deletions node/src/Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1529,7 +1529,7 @@ export class BaseTransaction<T extends BaseTransaction<T>> {
* Transactions allow the execution of a group of commands in a single step.
*
* Command Response:
* An array of command responses is returned by the RedisClient.exec command, in the order they were given.
* An array of command responses is returned by the GlideClient.exec command, in the order they were given.
* Each element in the array represents a command given to the transaction.
* The response for each command depends on the executed Redis command.
* Specific response types are documented alongside each method.
Expand All @@ -1540,7 +1540,7 @@ export class BaseTransaction<T extends BaseTransaction<T>> {
* .set("key", "value")
* .select(1) /// Standalone command
* .get("key");
* const result = await redisClient.exec(transaction);
* const result = await GlideClient.exec(transaction);
* console.log(result); // Output: ['OK', 'OK', null]
* ```
*/
Expand All @@ -1564,7 +1564,7 @@ export class Transaction extends BaseTransaction<Transaction> {
* Transactions allow the execution of a group of commands in a single step.
*
* Command Response:
* An array of command responses is returned by the RedisClusterClient.exec command, in the order they were given.
* An array of command responses is returned by the GlideClusterClient.exec command, in the order they were given.
* Each element in the array represents a command given to the transaction.
* The response for each command depends on the executed Redis command.
* Specific response types are documented alongside each method.
Expand Down
26 changes: 13 additions & 13 deletions node/tests/RedisClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from "@jest/globals";
import { BufferReader, BufferWriter } from "protobufjs";
import { v4 as uuidv4 } from "uuid";
import { ProtocolVersion, RedisClient, Transaction } from "..";
import { GlideClient, ProtocolVersion, Transaction } from "..";
import { RedisCluster } from "../../utils/TestUtils.js";
import { redis_request } from "../src/ProtobufMessage";
import { runBaseTests } from "./SharedTests";
Expand All @@ -30,15 +30,15 @@ import {
/* eslint-disable @typescript-eslint/no-var-requires */

type Context = {
client: RedisClient;
client: GlideClient;
};

const TIMEOUT = 50000;

describe("RedisClient", () => {
describe("GlideClient", () => {
let testsFailed = 0;
let cluster: RedisCluster;
let client: RedisClient;
let client: GlideClient;
beforeAll(async () => {
const standaloneAddresses =
parseCommandLineArgs()["standalone-endpoints"];
Expand Down Expand Up @@ -106,7 +106,7 @@ describe("RedisClient", () => {
it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])(
"info without parameters",
async (protocol) => {
client = await RedisClient.createClient(
client = await GlideClient.createClient(
getClientConfigurationOption(cluster.getAddresses(), protocol),
);
const result = await client.info();
Expand All @@ -125,7 +125,7 @@ describe("RedisClient", () => {
it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])(
"simple select test",
async (protocol) => {
client = await RedisClient.createClient(
client = await GlideClient.createClient(
getClientConfigurationOption(cluster.getAddresses(), protocol),
);
let selectResult = await client.select(0);
Expand All @@ -149,7 +149,7 @@ describe("RedisClient", () => {
it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])(
`can send transactions_%p`,
async (protocol) => {
client = await RedisClient.createClient(
client = await GlideClient.createClient(
getClientConfigurationOption(cluster.getAddresses(), protocol),
);
const transaction = new Transaction();
Expand All @@ -164,10 +164,10 @@ describe("RedisClient", () => {
it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])(
"can return null on WATCH transaction failures",
async (protocol) => {
const client1 = await RedisClient.createClient(
const client1 = await GlideClient.createClient(
getClientConfigurationOption(cluster.getAddresses(), protocol),
);
const client2 = await RedisClient.createClient(
const client2 = await GlideClient.createClient(
getClientConfigurationOption(cluster.getAddresses(), protocol),
);
const transaction = new Transaction();
Expand All @@ -189,7 +189,7 @@ describe("RedisClient", () => {
it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])(
"object freq transaction test_%p",
async (protocol) => {
const client = await RedisClient.createClient(
const client = await GlideClient.createClient(
getClientConfigurationOption(cluster.getAddresses(), protocol),
);

Expand Down Expand Up @@ -230,7 +230,7 @@ describe("RedisClient", () => {
it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])(
"object idletime transaction test_%p",
async (protocol) => {
const client = await RedisClient.createClient(
const client = await GlideClient.createClient(
getClientConfigurationOption(cluster.getAddresses(), protocol),
);

Expand Down Expand Up @@ -275,7 +275,7 @@ describe("RedisClient", () => {
it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])(
"object refcount transaction test_%p",
async (protocol) => {
const client = await RedisClient.createClient(
const client = await GlideClient.createClient(
getClientConfigurationOption(cluster.getAddresses(), protocol),
);

Expand Down Expand Up @@ -306,7 +306,7 @@ describe("RedisClient", () => {
options.protocol = protocol;
options.clientName = clientName;
testsFailed += 1;
client = await RedisClient.createClient(options);
client = await GlideClient.createClient(options);
return { client, context: { client } };
},
close: (context: Context, testSucceeded: boolean) => {
Expand Down
Loading
Loading