Skip to content

Commit

Permalink
fix examples
Browse files Browse the repository at this point in the history
Signed-off-by: Adar Ovadia <adarov@amazon.com>
  • Loading branch information
Adar Ovadia committed Sep 29, 2024
1 parent 0b719cb commit c457eaa
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 24 deletions.
16 changes: 8 additions & 8 deletions examples/node/cluster_example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async function appLogic(client: GlideClusterClient) {
const pong = await client.ping();
Logger.log("info", "app", `PING response: ${pong}`);

// Send INFO REPLICATION with routing option to all nodes
// Send INFO REPLICATION to all nodes
const infoReplResps = await client.info({
sections: [InfoOptions.Replication],
});
Expand Down Expand Up @@ -90,14 +90,14 @@ async function execAppLogic() {
"glide",
`Authentication error encountered: ${error}`,
);
throw error;
} else {
Logger.log(
"warn",
"glide",
`Client has closed and needs to be re-created: ${error}`,
);
}

Logger.log(
"warn",
"glide",
`Client has closed and needs to be re-created: ${error}`,
);

throw error;
case error instanceof TimeoutError:
// A request timed out. You may choose to retry the execution based on your application's logic
Expand Down
21 changes: 11 additions & 10 deletions examples/node/standalone_example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async function createClient(nodesList = [{ host: "localhost", port: 6379 }]) {
port: node.port,
}));

// Check `GlideClusterClientConfiguration` for additional options.
// Check `GlideClientConfiguration` for additional options.
return await GlideClient.createClient({
addresses: addresses,
// if the server uses TLS, you'll need to enable it. Otherwise the connection attempt will time out silently.
Expand All @@ -36,8 +36,8 @@ async function createClient(nodesList = [{ host: "localhost", port: 6379 }]) {

/**
* Executes the main logic of the application, performing basic operations
* such as SET, GET, PING, and INFO REPLICATION using the provided GlideClusterClient.
* @param client An instance of GlideClusterClient.
* such as SET, GET, PING, and INFO REPLICATION using the provided GlideClient.
* @param client An instance of GlideClient.
*/
async function appLogic(client: GlideClient) {
// Send SET and GET
Expand All @@ -47,7 +47,7 @@ async function appLogic(client: GlideClient) {
const getResponse = await client.get("foo");
Logger.log("info", "app", `Get response is: ${getResponse?.toString()}`);

// Send PING to all primaries (according to Redis's PING request_policy)
// Send PING to primary
const pong = await client.ping();
Logger.log("info", "app", `PING response: ${pong}`);
}
Expand All @@ -74,13 +74,14 @@ async function execAppLogic() {
"glide",
`Authentication error encountered: ${error}`,
);
throw error;
} else {
Logger.log(
"warn",
"glide",
`Client has closed and needs to be re-created: ${error}`,
);
}
Logger.log(
"warn",
"glide",
`Client has closed and needs to be re-created: ${error}`,
);

throw error;
case error instanceof TimeoutError:
// A request timed out. You may choose to retry the execution based on your application's logic
Expand Down
12 changes: 6 additions & 6 deletions examples/python/cluster_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ async def exec_app_logic():
"glide",
f"Authentication error encountered: {e}",
)
raise e
Logger.log(
LogLevel.WARN,
"glide",
f"Client has closed and needs to be re-created: {e}",
)
else:
Logger.log(
LogLevel.WARN,
"glide",
f"Client has closed and needs to be re-created: {e}",
)
raise e
except TimeoutError as e:
# A request timed out. You may choose to retry the execution based on your application's logic
Expand Down

0 comments on commit c457eaa

Please sign in to comment.